------- Comment #5 from h dot b dot furuseth at usit dot uio dot no  2006-10-17 
12:49 -------
Subject: Re:  Issues with -Wchar-subscripts

pinskia at gcc dot gnu dot org writes:
> 'a' in C is not of the type char but instead int so not warning
> there is correct really.

How about a -Warray-bounds option, maybe in -Wall, which tries to
catch array[negative index] and (when the array length is known)
array[too large positive index]?  That will also catch array['\300']
when the program meets a host where char is signed.

It'll give false alarms for fake variable-length arrays, but those are
not common and can be replaced with the real thing now.  This, I mean:
  struct Foo { blah blah; char array[1]; };
  struct Foo *foo = malloc(sizeof(struct Foo) + strlen(str));
  strcpy(foo->array, str);


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29455

Reply via email to