On Monday 26 September 2011, Matthew Gretton-Dann wrote:

> As far as I understand it -Warray-bounds should be emitting a warning
> for this case, but PR31227 seemed to be about removing these warnings.
> 
> The PR comments do not explain why the array accesses are valid and I'm
> hoping someone can shed some light on the situation - what are we missing?

The fix for PR was when the address of an element beyond the array is taken, 
but not actually dereferenced (used). For cases where the element is 
dereferenced it should warn IMHO. 

Note however that in this case it accesses an adjacent array of the same type 
in memory, and it is arguable if it should give a warning there or not. I have 
no strong opinion about this (I suspect that choosing for one variant gives 
false positives, and the other false negatives). It seems fortify_source has a 
similar problem, which is why they have added an option for it (1/2): 

http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html

I guess we need the same approach here. 

Thanks,
Dirk

Reply via email to