On Fri, May 24, 2013 at 6:23 AM, Jason Merrill <[email protected]> wrote:
> On 05/24/2013 01:23 AM, Richard Smith 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;
>> }
>>
>
> The ABI already deals with this case:
>
> ---
>
> Occasionally entities in local scopes must be mangled too (e.g. because
> inlining or template compilation causes multiple translation units to
> require access to that entity). The encoding for such entities is as
> follows:
>
> <local-name> := Z <function encoding> E <entity name> [<discriminator>]
> := Z <function encoding> E s [<discriminator>]
>
> <discriminator> := _ <non-negative number> # when number < 10
> := __ <non-negative number> _ # when number >= 10
>
> ...
> ---
>
> We just need to specify how lifetime-extended temporaries fit into this.
> And, I suppose, that we need to use <data-member-prefix> for strings in
> the various lambda contexts.
>
This may mean that copy-elision becomes part of the ABI in some cases. For
instance...
struct A { int &&r1; };
struct B { A &&a; char &&r2; };
char *f() {
static B c = { A(A{0}), 'x' };
return &c.r2;
};
Do we assign a mangling to the int temporary or not? It is
lifetime-extended if and only if the A copy is elided. For instance, g++
returns _ZGRZ1fvE1c1 with -fno-elide-constructors and _ZGRZ1fvE1c2 with
-felide-constructors.
_______________________________________________
cxx-abi-dev mailing list
[email protected]
http://sourcerytools.com/cgi-bin/mailman/listinfo/cxx-abi-dev