https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64423

            Bug ID: 64423
           Summary: Incorrect column number of -Wchar-subscripts
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chengniansun at gmail dot com

The column number of -Wchar-subscripts is not precise. It always starts at the
beginning of the statement. 

$: cat t.c
int a[100];

int f(char c) {
  return a[c] + a[c] + a[c];
}

$: 
$: gcc-trunk -Wchar-subscripts -c t.c
t.c: In function ‘f’:
t.c:4:3: warning: array subscript has type ‘char’ [-Wchar-subscripts]
   return a[c] + a[c] + a[c];
   ^
t.c:4:3: warning: array subscript has type ‘char’ [-Wchar-subscripts]
t.c:4:3: warning: array subscript has type ‘char’ [-Wchar-subscripts]

$: 
$: clang-trunk -Wchar-subscripts -c t.c
t.c:4:11: warning: array subscript is of type 'char' [-Wchar-subscripts]
  return a[c] + a[c] + a[c];
          ^~
t.c:4:18: warning: array subscript is of type 'char' [-Wchar-subscripts]
  return a[c] + a[c] + a[c];
                 ^~
t.c:4:25: warning: array subscript is of type 'char' [-Wchar-subscripts]
  return a[c] + a[c] + a[c];
                        ^~
3 warnings generated.

Reply via email to