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/44300] Spurious array subscript warning



------- Comment #3 from jmattson at vmware dot com  2010-05-27 20:31 -------
Admittedly, foo() makes some assumptions about alignment as originally written.
 A more pedantic version is:

static inline void
foo(int *p)
{
   if (p >= a + 1 && p < a + 10) {
      p[-1] = 0;
   }
}

gcc still generates a warning with this version.

Even if a[] and b[] overlap, the guard clause ensures that the expression
'p[-1]' is within the bounds of array a[].


-- 


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


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