I was looking at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68425

For testcase

    const int array[2] = { 1, 2, 3 ,6 ,89 ,193};


gcc 6.0.0 produces warnings like (spacing may get disturbed by gmail) :

68425.c: In function ‘main’:
68425.c:3:34: warning: excess elements in array initializer
     const int array[2] = { 1, 2, 3 ,6 ,89 ,193};
                                           ^
68425.c:3:34: note: (near initialization for ‘array’)
68425.c:3:37: warning: excess elements in array initializer
     const int array[2] = { 1, 2, 3 ,6 ,89 ,193};
                                               ^
68425.c:3:37: note: (near initialization for ‘array’)
68425.c:3:40: warning: excess elements in array initializer
     const int array[2] = { 1, 2, 3 ,6 ,89 ,193};
                                                   ^~
68425.c:3:40: note: (near initialization for ‘array’)
68425.c:3:44: warning: excess elements in array initializer
     const int array[2] = { 1, 2, 3 ,6 ,89 ,193};
                                                        ^~~
68425.c:3:44: note: (near initialization for ‘array’)


While clang gives :

68425.c:3:34: warning: excess elements in array initializer
    const int array[2] = { 1, 2, 3 ,6 ,89 ,193};
                                          ^
1 warning generated.


Wouldn't it be nice instead of multiple warnings if gcc gives single
warning like :

68425.c:3:34: warning: excess elements in array initializer (6
elements, expected 2)
    const int array[2] = { 1, 2, 3 ,6 ,89 ,193};
                                          ^




-- 
Thanks and Regards,
Prasad Ghangal

Reply via email to