On Thu, May 23, 2013 at 10:41 PM, John McCall <[email protected]> wrote:

> On May 23, 2013, at 10:23 PM, Richard Smith <[email protected]>
> 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.


Finding failed. In addition to the implications of the ODR, we have this:

[dcl.fct.spec]p4: "A string literal in the body of an extern inline
function is the same object in different translation units."

On the adding front, perhaps the simplest way to avoid generating such
extra symbols (at least, in most cases) would be to specify that a string
literal expression may produce the address of a different (static storage
duration) object each time it is evaluated.  However, even if we allow
that, I don't think it's reasonable for an unchanging static storage
duration pointer or reference to point at different objects depending on
who is asking.
_______________________________________________
cxx-abi-dev mailing list
[email protected]
http://sourcerytools.com/cgi-bin/mailman/listinfo/cxx-abi-dev

Reply via email to