<div style="font-family: arial, helvetica, sans-serif"><font size="2"><div class="gmail_quote">On Tue, Jun 19, 2012 at 1:20 AM, Jay Foad <span dir="ltr"><<a href="mailto:jay.foad@gmail.com" target="_blank">jay.foad@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'd really like to be able to get a warning when "almost all" elements<br>
of an array are initialised:<br>
<br>
#define N 8<br>
const int a[N] = { 3, 1, 4, 1, 5, 9, 2 };<br>
warning: some but not all array elements initialised<br></blockquote><div><br></div><div>At least in C++, this warning wouldn't make a lot of sense because all of the array elements *are* initialized. [dcl.init.aggr] 8.5.1/7: "If there are fewer initializers in the list than there are members in the aggregate, then each member not explicitly initialized shall be value-initialized (8.5)."</div>
<div><br></div><div>We would have a problem with lots of code which intended to initialized the first few elements, and zero out the rest.</div><div><br></div><div>Maybe someone has clever ideas about how to syntactically differentiate between these two use cases?</div>
</div></font></div>