4 ms·
Definitely not "working", yeah, but On MSVC, an all-zero string object is the correct representation for a std::string containing "" (and the memory leak is ea
by gavinsyancey 3y ago
Definitely not "working", yeah, but
On MSVC, an all-zero string object is the correct representation for a std::string containing "" (and the memory leak is easy to miss if you don't do it too much).
On both Clang and gcc, an all-zero string object is not using the short-string optimization -- it is a string with size zero, capacity zero, and an external buffer of nullptr. (On clang this happens because capacity is even, and on gcc because &str->buf != &str). Any code that attempts to access its null terminator will dereference the null pointer and crash immediately.
- dataflow 3y agoYeah I get that.