<br><br><div class="gmail_quote">On Tue, Jul 12, 2011 at 4:59 PM, Peter Geoghegan <span dir="ltr"><<a href="mailto:peter@2ndquadrant.com">peter@2ndquadrant.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 13 July 2011 00:28, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
<br>
> I think someone mentioned the idea of adding a separate warning for this<br>
> narrower case and, in the case of compiling for c99, suggesting a fixup of<br>
> using a flexible array. In the case of c89 at least it'd be a separate<br>
> warning that, if the pattern is used extensively in the codebase, could be<br>
> disabled separately from the more general warning (which would be adjusted<br>
> to ignore these cases).<br>
><br>
> This would allow for the bug that was mentioned to have been found, while<br>
> allowing you to disable this warning if you don't think the chance of such<br>
> bugs coming up is worth the code hygiene cost of the above construct or the<br>
> move to c99 would be worthwhile in your case.<br>
<br>
</div>While strictly speaking that would be a valid solution, it would also<br>
be overly-complex considering the benefits IMHO. I'd now have a flag<br>
to pass to Clang, but only to Clang, despite the fact that it's<br>
supposed to be a drop-in replacement for GCC. I'd now have to<br>
explicitly indicate that I was using C89.<br></blockquote><div><br>If you are compiling c89, that doesn't seem onerous - perhaps one day GCC could get smarter & start warning you about this or other superseded constructs if you continue to compile as c99 but avoid c99 features.<br>
<br>So, options that seem to be being discussed include:<br><br>1) suppress this warning in all cases where the array is of length 1 and the last element in a struct<br>  1.1) refinement: only when the length is specified explicitly and not via macro expansion, etc. (as John suggested)<br>
  1.2) refinement: under c99 recommend a fixup to use flexible arrays<br>2) split the warning in two, the second being the cases suppressed by the above option (probably less interesting if 1.1 is implemented)<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


Once again, the burden would be on application developers who are just<br>
using a demonstrably mainstream idiom, <br></blockquote><div><br>Mainstream in c89 with better alternatives in c99.<br></div></div>