[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
Richard Smith
richardsmith at google.com
Thu May 30 00:48:55 UTC 2013
On Fri, May 24, 2013 at 6:23 AM, Jason Merrill <jason at redhat.com> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20130529/e86b3adb/attachment.html>
More information about the cxx-abi-dev
mailing list