This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/29455] Issues with -Wchar-subscripts



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]