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/65679] New: Too strict alias analysis?


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65679

            Bug ID: 65679
           Summary: Too strict alias analysis?
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at robbertkrebbers dot nl

Consider the following example:

  #include<stdio.h>
  #include<stdint.h>

  int main() {
    int x = 1, y = 2, *p = &y, *q = &x + 1;
    if ((intptr_t)p == (intptr_t)q) {
      *q = 10;
      printf("%d %d %d\n", x, y, p == q);
    }
  }

When compiled with "gcc -pedantic -std=c99 -O2" (and even with
-fno-strict-aliasing added), the compiled program prints:

  1 2 0

So, despite the fact that is has been "observed" that p and q have identical
representations, they are still not being treated as equal.

Is this intended?


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