On 3 April 2016 at 16:56, Prasad Ghangal <prasad.ghan...@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.