On 09/03/2013 10:45 AM, Jakub Jelinek wrote: > On Tue, Sep 03, 2013 at 10:40:16AM -0500, Meador Inge wrote: >>> And I fail to see why the testcase should >>> not warn. Clearly you have a definition of a here and it doesn't have >>> an element >>> so the access is out of bounds. >> >> Not always, 'size_a' can be zero and the warning is worded such that the out >> of >> bounds access always happens. In fact, changing the code to 'size_a = 0' >> still >> issues a warning. > > How would that be different if you had that invalid access in a function > and never called the function, or called it only if (0) or similar? > We don't do reachability analysis, if any code we warn about can be > reachable from main, and still warn about invalid code, this is invalid > code, so it is IMHO just fine to warn about it.
True. Perhaps I am getting too caught up in the wording. I thought we typically use "may" for warnings that aren't definitive, but in this case we use "is" (instead of something like "may be"): warning: array subscript is above array bounds [-Warray-bounds] -- Meador Inge CodeSourcery / Mentor Embedded