The -Wchar-subscripts option doesn't seem to have any effect. IIRC,
it used to work at some point in the past but this test case doesn't
seem to trigger it in any compiler between 2.95 and 3.4 regardless
of whether char is signed or unsigned.
$ cat t.cpp && g++ --version && g++ -Wchar-subscripts t.cpp
char foo (const char *s)
return s [s ['\x80']];
int main ()
g++ (GCC) 3.4.0
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Confirmed, it only ever worked on a really arrays and not pointers.
Fixed on the mainline by:
2004-11-20 Joseph S. Myers <email@example.com>
* c-typeck.c (build_array_ref): Don't check for index == 0. Make
checks for neither argument being an array or pointer (swapping
the arguments if necessary), the array argument being a pointer to
or array of functions and for -Wchar-subscripts warnings upfront.
Oh, it is not fixed by that patch.
Subject: Bug 16307
Date: Sun Oct 29 18:38:26 2006
New Revision: 118154
2006-10-29 Dirk Mueller <firstname.lastname@example.org>
* typeck.c (build_array_ref): Warn for char subscriptions
* g++.dg/warn/Wchar-subscripts-2.C: New testcase.
Fixed in 4.3