This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Need suggestion about bug 68425


On 3 April 2016 at 16:56, Prasad Ghangal <prasad.ghangal@gmail.com> wrote:
>
> Also for
>
> int array[10];
> array[100]=10;
>
> Currently, GCC doesn't emit any warning (even with -Wall option)
>
> Wouldn't it be nice if GCC gives some warning like Clang, which gives:
>
> foo.c:4:3: warning: array index 100 is past the end of the array
> (which contains 10 elements) [-Warray-bounds]
>   array[100]=10;
>   ^     ~~~

Yes, it would be very nice. This is
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35587 which is quite old.
However, there is the issue of warning for code that is clearly not
executed (for example, within if(0){}). Not sure if Clang tracks that.

Cheers,

Manuel.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]