[cxx-abi-dev] Scope encoding of string literals in default arguments questions

Mark Mitchell mark at codesourcery.com
Mon Nov 11 06:52:42 UTC 2002



--On Friday, November 01, 2002 11:47:59 AM +0000 scott douglass 
<sdouglass at arm.com> wrote:

> Hi,
>
> I have some questions about the scope encoding of string literals in
> inline functions.  Consider,
>
>   bool g(const char*);
>
>   inline const char* f1(const char* p = "world");  // _ZZ2f1Es ?
>
>   inline const char* f1(const char* p) {
>     g(p);
>     g("hello");  // _ZZ2f1Es_0 ?
>     g("world");  // _ZZ2f1Es ?
>   }

I think that the only consistent thing to do is to move the default
argument into the callers; that is where it will be emitted.

> I'll also suggest some minor clarifications to the wording in 5.1.6:
>   "Note that this assumes that the same string literal occurring twice in
> a given function in fact represents a single entity, i.e. has a unique
> address."
>
> would be better as
>   "Note that this means that the same string literal occurring twice in a
> given inline function in fact represents a single entity, i.e. has a
> unique address.  It also means that string literals in inline functions
> do not "tail-share", i.e. the string literals "abc" and "bc" are
> completely distinct in inline functions."

Why?

> And
>   "even if subsequent optimization makes some of them unnecessary."
>
> would be better as
>   "even if subsequent optimization makes some of them unnecessary or base
> or member initializer expressions are re-ordered."

Agreed; I made that change.

> By the way, the ABI document's HTML has two occuranes "#scope-encoding"
> that should be "#mangling-scope".

Thanks; those are now fixed.

-- 
Mark Mitchell                mark at codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com



More information about the cxx-abi-dev mailing list