[cfe-dev] warning request: partial array initialisation

Jay Foad jay.foad at gmail.com
Tue Jun 19 12:31:41 PDT 2012

On 19 June 2012 18:56, Chandler Carruth <chandlerc at google.com> wrote:
> When we're designing warnings that try to catch bugs, we need to focus on
> getting the warning into a state that is easier to explain and cope with for
> our users. For example:
> 1) A warning that is *always* a bug in the code is easy: the user can't
> really complain, their code is simply wrong.
> 2) A warning that directs innocent users to some alternate syntax which hase
> equivalent semantics but is more explicit / clear / less bug-prone.

Fair point. I agree with the general principle that the compiler
shouldn't warn when there's no better way to express what you really
want; and if I really want

  static int a[1000000] = { 1, 2, /* all the rest 0 */ };

then there's no better way of writing it.

> Also, this seems really like a coding convention or style you would like to enforce, and so I suspect a separate tool would be better suited to it.

Yup. I'd love a general purpose scriptable tool for doing this kind of
thing. Maybe it's time I looked at Coccinelle...


More information about the cfe-dev mailing list