http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54365
--- Comment #8 from Florian Weimer 2012-08-30
13:56:04 UTC ---
(In reply to comment #7)
> This is not surprising, just use integer arithmetic instead of pointer
> arithmetic. Pointer arithmetic not only has undefined wrapping, it is defined
> on
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54365
--- Comment #7 from Jakub Jelinek 2012-08-30
13:45:13 UTC ---
This is not surprising, just use integer arithmetic instead of pointer
arithmetic. Pointer arithmetic not only has undefined wrapping, it is defined
only within the bounds of the obje
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54365
--- Comment #6 from Florian Weimer 2012-08-30
13:33:05 UTC ---
(In reply to comment #5)
> -fwrapv doesn't appear to make a difference:
>
> $ gcc compilerbug.c
> $ ./a.out
> it wraps
> $ gcc -O2 compilerbug.c
> $ ./a.out
> no wrap
> $ gc
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54365
--- Comment #5 from Greg Law 2012-08-30 13:23:54 UTC
---
-fwrapv doesn't appear to make a difference:
$ gcc compilerbug.c
$ ./a.out
it wraps
$ gcc -O2 compilerbug.c
$ ./a.out
no wrap
$ gcc -O2 -fwrapv compilerbug.c
$ ./a.out
no wrap
$
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54365
Florian Weimer changed:
What|Removed |Added
CC||fweimer at redhat dot com
--- Comment #4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54365
Jakub Jelinek changed:
What|Removed |Added
Status|UNCONFIRMED |RESOLVED
CC|
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54365
--- Comment #2 from Greg Law 2012-08-24 18:38:24 UTC
---
Yes, I think you're right: I hadn't appreciated that.
Still, even though it's undefined, it's slightly strange behaviour for the
compiler to adopt. I guess it's reasonable to close this bu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54365
--- Comment #1 from Andrew Pinski 2012-08-24
18:23:50 UTC ---
This code as far as I Know is undefined. Pointer arithmetic overflow is
undefined and not wrapping. Mainly because there is no way to add a positive
number to an object and get back