------- Comment #10 from rguenth at gcc dot gnu dot org  2010-05-28 17:51 
-------
(In reply to comment #9)
> Okay.  What if we stick with equality operators, then?
> 
> static inline void
> foo(int *p)
> {
>    if (p == a + 1 || p == a + 2) {
>       p[-1] = 0;
>    }
> }
> 
> This code results in the same warning.

Yep.  That's because a and b might not bind locally and thus we do not
know whether &b[0] == &a[1].

We don't warn for -fno-common, but in this case we might still
optimize the comparison.

Confirmed for the testcase in comment #9.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
          Component|c                           |middle-end
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-05-28 17:51:52
               date|                            |
            Summary|Spurious array subscript    |Spurious array subscript
                   |warning                     |warning, &b[0] == &a[1] is
                   |                            |not folded


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

Reply via email to