[Bug c/49330] Integer arithmetic on addresses optimised with pointer arithmetic rules

harald at gigawatt dot nl gcc-bugzilla@gcc.gnu.org
Wed Jun 8 20:42:00 GMT 2011


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

--- Comment #1 from Harald van Dijk <harald at gigawatt dot nl> 2011-06-08 20:42:04 UTC ---
A similar example, but one which does not convert the integer back to a
pointer:

#include <stdio.h>
#include <stdlib.h>
int a;
int main() {
  unsigned long b = (unsigned long) &a - 134518548;
  volatile unsigned long c = b;
  if (c == 0) {
    if (b != 0) abort ();
  }
  printf("%lu\n", c);
  return a;
}

This should never abort. It aborts on my system (with -m32).



More information about the Gcc-bugs mailing list