<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 22, 2015 at 10:43 PM, Yury Gribov <span dir="ltr"><<a href="mailto:y.gribov@samsung.com" target="_blank">y.gribov@samsung.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 01/22/2015 08:39 PM, David Blaikie wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Thu, Jan 22, 2015 at 1:38 AM, Yury Gribov <<a href="mailto:tetra2005@gmail.com" target="_blank">tetra2005@gmail.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi rsmith, eli.friedman,<br>
<br>
This patch liberalizes -Wglobal-constructors to not emit warning if<br>
constructor is likely to be optimized away. This covers important<br>
LinkerInitialized idiom used e.g. in libsanitizer and Chromium:<br>
enum LinkerInitialized { LINKER_INITIALIZED };<br>
class Mutex {<br>
public:<br>
inline Mutex(base::LinkerInitialized) {}<br>
};<br>
Mutex mu(LINKER_INITIALIZED); // Will be optimized away<br>
<br>
</blockquote>
<br>
While this is probably a useful improvement to C++98 code, is there any<br>
reason this code couldn't use C++11's constexpr instead? (which I think<br>
would already not produce the warning without needing to change the<br>
compiler)<br>
</blockquote>
<br></span>
Constexpr would work in simple cases but will fail if class includes an array (for-loops are prohibited in constexpr but all members have to be initialized).</blockquote><div><br>Got an example of this? I'd imagine an in-class initializer might suffice for the array. ( int x[3] = {}; ) ?<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888"><br>
<br>
-Y<br>
<br>
</font></span></blockquote></div><br></div></div>