https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108626
--- Comment #6 from Jiang An <de34 at live dot cn> --- (In reply to Marat Radchenko from comment #5) > So, does "String literals, and compound literals with const-qualified types, > need not designate distinct objects." apply here or not? If not, how does > the case where it applies look like? I strongly believe that when compiling as C, the objects in your example are allowed to be merged. But I'm not sure whether this is applicable to C++. In C++ one may write: constexpr char x = a[0]; // OK. if constexpr (a == b) { // If the objects are merged then the following code is in affect. constexpr char y = b[0]; // Error! Because `b` is not usable in constant expressions. } I'm afraid that it would be unreasonable for compiler to handle such confusing case. > https://en.cppreference.com/w/c/language/compound_literal explicitly says > (though I do understand this is not a 100% reliable source): > > Compound literals of const-qualified character or wide character array types > may share storage with string literals. > > ---- > (const char []){"abc"} == "abc" // might be 1 or 0, implementation-defined > ---- > > Comparison with string literals isn't actually implementation-defined but > instead unspecified behavior, but the point here is that they think it is > possible memory is shared. I've corrected the comment on cppreference. Now it's saying "unspecified".