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

--- Comment #16 from Alexander Cherepanov <ch3root at openwall dot com> ---
On 2015-11-23 14:58, rguenth at gcc dot gnu.org wrote:
> Note that in practice it needs exposal of the address constant to trigger the
> bogus optimization.

No. The program:

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

int main()
{
   // make sure our allocation will cross 0x80000000 boundary
   // but still will not violate limits of gcc
   size_t len = 0x7fffffff;
   char *p1 = malloc(len);
   char *volatile v = p1 + len;
   char *p2 = v;
   long l1 = (long)(uintptr_t)p1;
   long l2 = (long)(uintptr_t)p2;
   if (l2 < l1) {
     long z = p2 - p1;
     if (z < 0)
       printf("%ld\n", z);
   }
}

prints a positive number for me even though it guards against it. gcc 
5.2 with -m32 -O2.

Reply via email to