https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105876

--- Comment #5 from Kevin Hendricks <kevin.b.hendricks at icloud dot com> ---
It was declared in sg_constants.h as:

extern const std::string MAIN_EXTERN_CONST_STRING;

But why was its global nature lost:

Based on nm output:

./no_lto_test:0000000000001210 t
_GLOBAL__sub_I__Z24MAIN_EXTERN_CONST_STRINGB5cxx11
./no_lto_test:00000000000041e0 B _Z24MAIN_EXTERN_CONST_STRINGB5cxx11
./no_lto_test:0000000000004220 b _ZL24TEST_STATIC_CONST_STRING

---

./lto_test:0000000000004100 b _Z24MAIN_EXTERN_CONST_STRINGB5cxx11
./lto_test:00000000000040e0 b _ZL24TEST_STATIC_CONST_STRING

and there is no global initialization routine anymore at all


So you are saying this is because a std::string constructor can not be
considered const even though it is a object that can be fully constructed and
allocated in pieces as a fixed structure datatype.

So my solution is everywhere we use extern const std::string, I either have to
change it to an untyped define/macro and give up type safety or change it to 
be a:

 extern const char * 

just so that it gets initialized as a proper global variable?

That really makes std::string a second class citizen.

Reply via email to