[cxx-abi-dev] Fwd: 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
Fri May 24 04:56:31 UTC 2013


Consider:

// tu1
struct A { static constexpr const char *p = "foo"; };
const char *q = A::p;
// tu2
struct A { static constexpr const char *p = "foo"; };
const char *r = A::p;

We are required to ensure that q == r, but gcc, clang, and EDG all fail to
do so. Therefore we presumably need to give the string literal a mangled
name. Likewise for string literals which appear within constexpr function
bodies:

// tu1
constexpr const char *get() { return "bar"; }
const char *a = get();
// tu2
constexpr const char *get() { return "bar"; }
const char *b = get();

... and also for lifetime-extended temporaries:

struct X { int n; };
struct B { static constexpr X &&x = {0}; };
X &y = B::x; // must be same X object in all TUs

(Both Clang and g++ have a rejects-valid on this, but EDG accepts it.)

... and likewise for lifetime-extended arrays underlying
std::initializer_list objects.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20130523/53db991a/attachment.html>


More information about the cxx-abi-dev mailing list