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 () { foo ("\x80"); } 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 <joseph@codesourcery.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.
Testing patch.
Subject: Bug 16307 Author: mueller Date: Sun Oct 29 18:38:26 2006 New Revision: 118154 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118154 Log: 2006-10-29 Dirk Mueller <dmueller@suse.de> PR c++/16307 * typeck.c (build_array_ref): Warn for char subscriptions on pointers. * g++.dg/warn/Wchar-subscripts-2.C: New testcase. Added: trunk/gcc/testsuite/g++.dg/warn/Wchar-subscripts-2.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/typeck.c trunk/gcc/testsuite/ChangeLog
Fixed in 4.3