<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><b><font face="monospace, monospace">    struct S { int i; };</font></b></div><div><b><font face="monospace, monospace">    S s{{0}};<br></font></b><br></div><div><b>Clang</b>: `<b>warning</b>: braces around scalar initializer [-Wbraced-scalar-init]`</div></div></div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>or, with more braces:</div></div></div></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div> `<b>warning</b>: too many braces around scalar initializer [-Wmany-braces-around-scalar-init]<br>(consistent as a warning since at least clang 3.0.0)<br></div></div></div></div></div></blockquote><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><b>GCC</b>: `<b><font color="#ff0000">error</font></b>: braces around scalar initializer for type 'int'`</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>(consistent as an error since ~gcc 4.4.7)</div></div></div></div></blockquote><div><b>MSVC</b>: no warning (with \Wall)<br></div><div><div><div><b>Intel</b>: warning #1119: extra braces are nonstandard<br></div></div><div><br></div><div>I believe that this is a non-standard extension in Clang. Can anyone confirm?</div><div>Does the standard does mandate an error here?</div><div>If so then is there any flag to make this an error in Clang?</div><div><div><font face="monospace, monospace">(-pedantic-errors</font> flag makes no difference, for gcc or for clang.)</div>Maybe it's for MSVC / EDG compatibility? Or C compatibility? What reason?</div><div><br></div><div>An error allows compile-time code to distinguish between scalar and non-scalar,</div><div>to count the number of allowable braces and so to detect array rank & dims.</div><div><br></div><div>On the other hand, an error forces different syntax for initializing scalar and non-scalar</div><div>so disallows generic 'uniform' braced-init syntax where there may be scalars.</div><div><br></div><div>Thanks for any thoughts,</div><div>Will</div><div><br></div><div>Here are some issues/DRs & commits that may or may not be relevant<br></div><div>An old pre-11 issue</div><div><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">632. </span><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#632" style="font-family:"Times New Roman";font-size:medium">Brace-enclosed initializer for scalar member of aggregate</a><br>explains that this was a C/C++ incompatibility, says it was resolved by <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm">Initializer Lists</a></div><div>(LOL) (I can't see how or where it is resolved)</div><div><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1501">h1501. Nested braces in list-initialization</a><br></div></div><div>As part of changes for <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1467">DR1467 List-initialization of aggregate from same-type object</a></div><div>this Clang commit<br><a href="http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20150209/123171.html">r228896 </a>- Improve the "braces around scalar init" warning to determine whether to warn</div></div></div></div></div></div>