Re: Need suggestion about bug 68425

2016-04-03 Thread Prasad Ghangal
On 5 March 2016 at 01:06, David Malcolm  wrote:
> On Wed, 2016-02-24 at 17:56 +0530, Prasad Ghangal wrote:
>> Thanks Prathamesh and Joseph for your suggestions.
>>
>> Here is my updated patch :
>>
>> for test cases:
>>
>> const int array[5] = {1, 2, 3};
>> const int array1[3] = {1, 2, 3, 6};
>> const int array2[4] = {1, 2, 3, 6, 89};
>> const int array3[5] = {1, 2, 3, 6, 89, 193};
>> const int array4[3] = {1, 2, 3, 6, 89, 193};
>> const int array5[1] = {1, 2, 3, 6, 89, 193};
>> const int array6[3] = {1, 2, 3, 6, 89, 193;
>> const int array7[5] = {1, 2, 3, 6, 89, 193}
>> const int array8[5] = {1, 2, 3, 6, 89, 193
>>
>>
>>
>> It gives:
>>
>> 68425.c: In function ‘main’:
>> 68425.c:4:37: warning: excess elements in array initializer (4
>> elements, expected 3)
>>  const int array1[3] = {1, 2, 3, 6};
>>^
>> 68425.c:4:37: note: (near initialization for ‘array1’)
>> 68425.c:5:40: warning: excess elements in array initializer (5
>> elements, expected 4)
>>  const int array2[4] = {1, 2, 3, 6, 89};
>>^~
>> 68425.c:5:40: note: (near initialization for ‘array2’)
>> 68425.c:6:44: warning: excess elements in array initializer (6
>> elements, expected 5)
>>  const int array3[5] = {1, 2, 3, 6, 89, 193};
>>  ^~~
>> 68425.c:6:44: note: (near initialization for ‘array3’)
>> 68425.c:7:37: warning: excess elements in array initializer (6
>> elements, expected 3)
>>  const int array4[3] = {1, 2, 3, 6, 89, 193};
>>^
>> 68425.c:7:37: note: (near initialization for ‘array4’)
>> 68425.c:8:31: warning: excess elements in array initializer (6
>> elements, expected 1)
>>  const int array5[1] = {1, 2, 3, 6, 89, 193};
>>^
>> 68425.c:8:31: note: (near initialization for ‘array5’)
>> 68425.c:9:37: warning: excess elements in array initializer (6
>> elements, expected 3)
>>  const int array6[3] = {1, 2, 3, 6, 89, 193;
>>^
>> 68425.c:9:37: note: (near initialization for ‘array6’)
>> 68425.c:9:47: error: expected ‘}’ before ‘;’ token
>>  const int array6[3] = {1, 2, 3, 6, 89, 193;
>>^
>> 68425.c:14:1: error: expected declaration or statement at end of
>> input
>>  }
>>  ^
>
> Those caret locations look wrong to me - they don't seem to be
> underlining the pertinent source.  Is that what the patched compiler is
> printing, or did things get messed up somewhere via email?
>
> (I tried the patch, but it didn't quite apply cleanly against my
> working copy)
>
> As mentioned before, I think the ideal behavior would be to underline
> *all* of the surplus elements, like this:
>
> 68425.c: In function ‘main’:
> 68425.c:4:37: warning: excess elements in array initializer (4
> elements, expected 3)
>  const int array1[3] = {1, 2, 3, 6};
>  ^
> 68425.c:4:37: note: (near initialization for ‘array1’)
> 68425.c:5:40: warning: excess elements in array initializer (5
> elements, expected 4)
>  const int array2[4] = {1, 2, 3, 6, 89};
> ^~
> 68425.c:5:40: note: (near initialization for ‘array2’)
> 68425.c:6:44: warning: excess elements in array initializer (6
> elements, expected 5)
>  const int array3[5] = {1, 2, 3, 6, 89, 193};
> ^~~
> 68425.c:6:44: note: (near initialization for ‘array3’)
> 68425.c:7:37: warning: excess elements in array initializer (6
> elements, expected 3)
>  const int array4[3] = {1, 2, 3, 6, 89, 193};
>  ^~
> 68425.c:7:37: note: (near initialization for ‘array4’)
> 68425.c:8:31: warning: excess elements in array initializer (6
> elements, expected 1)
>  const int array5[1] = {1, 2, 3, 6, 89, 193};
>^~~~
> 68425.c:8:31: note: (near initialization for ‘array5’)
> 68425.c:9:37: warning: excess elements in array initializer (6
> elements, expected 3)
>  const int array6[3] = {1, 2, 3, 6, 89, 193;
>  ^~
> 68425.c:9:37: note: (near initialization for ‘array6’)
> 68425.c:9:47: error: expected ‘}’ before ‘;’ token
>  const int array6[3] = {1, 2, 3, 6, 89, 193;
>^
> 68425.c:14:1: error: expected declaration or statement at end of input
>  }
>  ^
>
> You can use "make_location" to build a range; see e.g. this fragment
> from the C++ frontend:
>
>   /* Create a location of the form:
> type_name{i, f}
> ^~~
>  with caret == start at the start of the type name,
>  finishing at the closing brace.  */
>   location_t finish_loc
>

Re: Need suggestion about bug 68425

2016-04-03 Thread Manuel López-Ibáñez
On 3 April 2016 at 16:56, Prasad Ghangal  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.


gcc-6-20160403 is now available

2016-04-03 Thread gccadmin
Snapshot gcc-6-20160403 is now available on
  ftp://gcc.gnu.org/pub/gcc/snapshots/6-20160403/
and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.

This snapshot has been generated from the GCC 6 SVN branch
with the following options: svn://gcc.gnu.org/svn/gcc/trunk revision 234702

You'll find:

 gcc-6-20160403.tar.bz2   Complete GCC

  MD5=c6f05e466aa5914de385e1f70b28c578
  SHA1=6ea72bcc203cdb0c60f2bf21c6f514254f4d9bf7

Diffs from 6-20160327 are available in the diffs/ subdirectory.

When a particular snapshot is ready for public consumption the LATEST-6
link is updated and a message is sent to the gcc list.  Please do not use
a snapshot before it has been announced that way.