<div dir="ltr">Hi,<div><br></div><div>on trunk, libc++ relies on undefined initialization order of global initializers when using gcc:</div><div><br></div><div>1. __start_std_streams in iostream.cpp calls locale::id::_init, which assigns an id to each locale::facet in an initializer</div>
<div><br></div><div>2. Every facet has a static locale::id id, whose constructor sets the facet's id to 0*</div><div><br></div><div>If 2 runs after 1, it clobbers the facet's assigned consecutive id, causing exceptions to be thrown when e.g. running code like "cout << endl".</div>
<div><br></div><div>To fix this, the attached patch lets _LIBCPP_CONSTEXPR evaluate to "constexpr" instead of nothing with gcc. locale::id's constructor is marked _LIBCPP_CONSTEXPR, which ensures that it won't get an initializer that could potentially run after the iostream.cpp initializer. (This remains broken when building with msvc.)</div>
<div><br></div><div>Once _LIBCPP_CONSTEXPR is available, bitset fails to compile since gcc doesn't define __SIZE_WIDTH__, so switch bitset to use __SIZEOF_SIZE_T__ which both clang and gcc define.</div><div><br></div>
<div>Pair-programmed/debugged with Dana Jansens.</div><div><br></div><div>Nico</div>























</div>