[Bug c/44300] Spurious array subscript warning

rguenth at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri May 28 16:40:00 GMT 2010



------- Comment #8 from rguenth at gcc dot gnu dot org  2010-05-28 16:40 -------
(In reply to comment #7)
> So, you are saying that given an arbitrary pointer p, it is impossible to
> determine whether or not p points to an element of array a[], because comparing
> pointers to different objects is undefined?  I find that hard to believe, but
> I'm no standards lawyer.

6.5.8/5 says that (note it only applies to relational operators, not
equality operators).

> Your suggested rewrite results in the same error.

That's unfortunate.  The following doesn't warn for me (but make
sure it's an identity transform):

   if (p > a && p < a + 10) {
      a[p - a - 1] = 0;
   }


-- 


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



More information about the Gcc-bugs mailing list