This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/44300] Spurious array subscript warning
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 May 2010 16:40:30 -0000
- Subject: [Bug c/44300] Spurious array subscript warning
- References: <bug-44300-19243@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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