[cxx-abi-dev] need mangling for string literals and lifetime-extended temporaries used in static constexpr member initializers and for string literals in constexpr functions

John McCall rjmccall at apple.com
Fri May 24 05:41:15 UTC 2013


On May 23, 2013, at 10:23 PM, Richard Smith <richardsmith at google.com> wrote:
> So... this problem was not really new in C++11. In C++98 it can be witnessed for an inline function such as:
> 
> inline const char *get() {
>   static const char *str = "foo";
>   return str;
> }

How is this different from the following?

  inline const char *get_nostatic() { return "foo"; }

or

  inline const char *get_separate() {
    const char *temp = "foo";
    static const char *str = tmp;
    return str;
  }

Please find or add something in the standard which will allow us to
not export a symbol for every string literal(*) that happens to be used
in a function with weak linkage.

John.


More information about the cxx-abi-dev mailing list