[cfe-dev] no warning for arrays that are too short?

Дмитрий Дьяченко dimhen at gmail.com
Wed Dec 5 22:23:19 PST 2012


FYI

$ gcc -Wuninitialized -O a.c
a.c: In function 'main':
a.c:5:13: warning: '*((void *)&array+24)' is used uninitialized in
this function [-Wuninitialized]
a.c:10:14: note: 'array' was declared here

$ gcc --version
gcc (GCC) 4.7.2 20120921 (Red Hat 4.7.2-2)

Thanks,
Dmitry

2012/12/6 Richard Smith <richard at metafoo.co.uk>:
> On Wed, Dec 5, 2012 at 6:07 PM, Jordan Rose <jordan_rose at apple.com> wrote:
>>
>> If you want checking of array parameter bounds, you have to say "double
>> arg[static 4]".
>
>
> Given that that's a C-only feature, it wouldn't seem unreasonable to also
> provide a warning for the non-static case (for use in C++). You can use
> 'const double (&arg)[4]' in C++, but that doesn't allow arrays larger than 4
> elements.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>



More information about the cfe-dev mailing list