[cfe-dev] Constant C string fix

Eli Friedman eli.friedman at gmail.com
Tue Dec 9 13:56:04 PST 2008


On Tue, Dec 9, 2008 at 11:05 AM, David Chisnall <csdavec at swansea.ac.uk> wrote:
> The constant C string implementation in CodeGenModule is incorrect.
> When you do str + "\0", you are appending a C string to the string,
> and so it inserts all of the characters before the first NULL byte
> into the C++ string.  Since \0 is the first byte, (str + "\0") ==
> str.  This means anything calling GetAddrOfConstantCString() is
> getting the wrong result.  I found this due to the ObjC class lookup
> function being passed unterminated strings - it also explains the
> random crashes on Linux in the ObjC load function.  I haven't checked
> if this pattern is being used anywhere else.

Not that it really matters, but it looks like the code for __func__
and friends was using the same pattern.

-Eli



More information about the cfe-dev mailing list