[libcxx-commits] [libcxx] [libc++] Replace __resize_default_init with resize_and_overwrite (PR #157121)

James Y Knight via libcxx-commits libcxx-commits at lists.llvm.org
Fri Sep 19 11:54:13 PDT 2025


jyknight wrote:

`__resize_default_init` was a tested, nonstandard public API (that is, intentionally in the "public:" access section) on libc++'s std::string -- so, I'd say, not really dead code even if the internal implementation no longer needs to call it. I don't think calling internal private methods through a "bug" in the language is a better option than that!

And as it happens, I just had to fix some other code doing a trick similar to the evil hack in Folly, in order to access the private methods `__set_long_cap`, `__set_long_size`, `__set_long_pointer`, which were removed yesterday by 8dae17be2991cd7f0d7fd9aa5aecd064520a14f6 -- an entirely reasonable code cleanup. Those were _actually_ private methods of the string class, of course nobody external could be calling them...except for that weird hole in class member access control from explicit template instantiation. (I wish that spec hole could be fixed...)

And I'm not worried about a silent regression -- we do catch it -- it's only "silent" because we intentionally implemented presence-detection for the nonstandard method, instead of unconditionally calling it.

https://github.com/llvm/llvm-project/pull/157121


More information about the libcxx-commits mailing list