<div dir="ltr">On Mon, Aug 19, 2013 at 9:36 AM, Howard Hinnant <span dir="ltr"><<a href="mailto:hhinnant@apple.com" target="_blank">hhinnant@apple.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ok, I've seen this one before:<br>
<br>
------------------------------------------------------------------------<br>
r160785 | hhinnant | 2012-07-26 12:14:37 -0400 (Thu, 26 Jul 2012) | 1 line<br>
<br>
locale::id really needs to be constructed at compile time.<br>
------------------------------------------------------------------------<br>
Index: include/__locale<br>
===================================================================<br>
--- include/__locale    (revision 160784)<br>
+++ include/__locale    (revision 160785)<br>
@@ -119,7 +119,7 @@<br>
<br>
     static int32_t __next_id;<br>
 public:<br>
-    _LIBCPP_INLINE_VISIBILITY id() {}<br>
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR id() :__id_(0) {}<br>
 private:<br>
     void __init();<br>
     void operator=(const id&); // = delete;<br>
<br>
The old design was to count on the loader to zero out the id, and if the ctor happened afterwards, it did nothing.  This was replaced with an attempt to force the construction at compile time.  I don't recall exactly why the old design started failing, but it did, at about the same time constexpr was introduced into clang.<br>

<br>
Unfortunately we can not apply constexpr to:<br>
<div class="im"><br>
locale::id ctype<char>::id;<br>
<br>
</div>because it isn't truly const.  It gets modified the first time its __get() function gets called.<br></blockquote><div><br></div><div>A static member where the called constructor constructor is constexpr is guaranteed to be constructed at compile-time by the C++11 standard.  You shouldn't need to apple constexpr to the variable itself.</div>
<div><br></div><div>-Eli  </div></div></div></div>