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 #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


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