[cxx-abi-dev] string constant mangling

Jason Merrill jason at redhat.com
Fri Jan 6 15:53:24 UTC 2012


On 03/08/2011 04:12 PM, David Vandevoorde wrote:
> On Mar 8, 2011, at 11:43 AM, Jason Merrill wrote:
>
>> It occurs to me that now with constexpr, string constants can appear in a constant expression:
>>
>> template<typename T>  constexpr T f(const T* p) { return p[0]; }
>> template<int>  struct N { };
>> template<typename T>  N<f((const T*)"1")>  g(T);
>> template<typename T>  N<f((const T*)"2")>  g(T);
>>
>> Here the two 'g's are different templates.
>
> Ouch :-(  I guess another tweak is needed then.

So,

  L <string type> <value string> E

where the string value is encoded in hex, omitting the terminal NUL?

Maybe use an MD5 hash for strings longer than 16 bytes?

Jason



More information about the cxx-abi-dev mailing list