------- Comment #25 from falk at debian dot org 2006-02-18 13:25 ------- (In reply to comment #24) > We need to allow offsetting beyond the declared array size if this array is > the > last member of a structure. This is refered to as "malloc trick" to allocate > variable sized structures with a flexible array member. Due to compilers > lacking > support for the correct char str[] declaration you will find all of > char str[0] (GNU extension) > char str[] > char str[1] > char str[4] (or whatever number) > so in this case we need to allow all accesses, or with a separate warning flag > only warn if the decl was not one of [0], [] or [1].
I tried to handle this by never warning for any size-0 or size-1 array. Is there some way to check that this array is in fact the last member of a struct? That would clearly be better. I'd still consider warning for sizes >1, because it's probably rare enough to not justify the false negatives we get otherwise. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8268