[cfe-dev] warning request: partial array initialisation

Matthieu Monrocq matthieu.monrocq at gmail.com
Tue Jun 19 10:36:30 PDT 2012


On Tue, Jun 19, 2012 at 7:01 PM, Chris Hall
<chris.hall.list at highwayman.com>wrote:

> Chandler Carruth wrote (on Tue 19-Jun-2012 at 17:50 +0100)
> >
> > On Tue, Jun 19, 2012 at 1:20 AM, Jay Foad <jay.foad at gmail.com> wrote:
> ....
> >>  #define N 8
> >>  const int a[N] = { 3, 1, 4, 1, 5, 9, 2 };
> >> warning: some but not all array elements initialised
> ...
> > Maybe someone has clever ideas about how to syntactically differentiate
> > between these two use cases?
>
>   const int a[N] = { ..... } __attribute__((all_explicitly_initialised))
>
> Chris
>
>
> Would a heuristic be acceptable ?

If the number of initializer is in [.9 * N, N) then it looks likely it is a
bug. The .9 factor could probably benefit from some tuning, maybe as low as
.5 would pass.

-- Matthieu.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120619/48507078/attachment.html>


More information about the cfe-dev mailing list