[Bug c/24756] pointer arithmetic on ia32 uses signed divide

2005-11-10 Thread pinskia at gcc dot gnu dot org
--- Comment #10 from pinskia at gcc dot gnu dot org 2005-11-10 14:09 --- (In reply to comment #9) > What you are saying is that: > Pointer arithmetic is only valid on elements of the same array that are > adjacent, and that any other uses of pointer arithmetic produces undefined > behav

[Bug c/24756] pointer arithmetic on ia32 uses signed divide

2005-11-10 Thread j3p0uk at hotmail dot com
--- Comment #9 from j3p0uk at hotmail dot com 2005-11-10 14:02 --- Sorry - I don't mean to pester you, I would just like to clarify your final point. What you are saying is that: Pointer arithmetic is only valid on elements of the same array that are adjacent, and that any other uses o

[Bug c/24756] pointer arithmetic on ia32 uses signed divide

2005-11-10 Thread pinskia at gcc dot gnu dot org
--- Comment #8 from pinskia at gcc dot gnu dot org 2005-11-10 13:58 --- If pointer1 and pointer2 are not in the same array (+-1 element), the behavior is undefined so what GCC is doing for your case is fine. -- pinskia at gcc dot gnu dot org changed: What|Removed

[Bug c/24756] pointer arithmetic on ia32 uses signed divide

2005-11-10 Thread j3p0uk at hotmail dot com
--- Comment #7 from j3p0uk at hotmail dot com 2005-11-10 13:54 --- Created an attachment (id=10201) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10201&action=view) More correct test program Here is a test program designed to show the problem more clearly. When run the pointer ar

[Bug c/24756] pointer arithmetic on ia32 uses signed divide

2005-11-10 Thread j3p0uk at hotmail dot com
--- Comment #6 from j3p0uk at hotmail dot com 2005-11-10 13:49 --- I was not intending to show a correct fix for the problem, my simple test program was merely intended to show that given sufficient distance between 2 pointers the result from ptr_a - ptr_b can be incorrect. I am not sur

[Bug c/24756] pointer arithmetic on ia32 uses signed divide

2005-11-09 Thread pinskia at gcc dot gnu dot org
--- Comment #5 from pinskia at gcc dot gnu dot org 2005-11-09 17:30 --- This is invalid because otherwise you get the incorrect answer for &a[3]-&a[4]: a = 0x8049668 b = 0x804966c pointer ( a - b ) 0x non-pointer ( ( ((un

[Bug c/24756] pointer arithmetic on ia32 uses signed divide

2005-11-09 Thread j3p0uk at hotmail dot com
--- Comment #4 from j3p0uk at hotmail dot com 2005-11-09 17:25 --- The test case was a simple test case where I tried to show the mathematical behaviour in as simple a way as possible. The reason I thought that this may be a bug is because the behaviour on a 64-bit system is different a

[Bug c/24756] pointer arithmetic on ia32 uses signed divide

2005-11-09 Thread rguenth at gcc dot gnu dot org
--- Comment #3 from rguenth at gcc dot gnu dot org 2005-11-09 15:53 --- Note that obtaining the difference of pointers that don't point to the same object is invoking undefined behavior, too. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24756

[Bug c/24756] pointer arithmetic on ia32 uses signed divide

2005-11-09 Thread pinskia at gcc dot gnu dot org
--- Comment #2 from pinskia at gcc dot gnu dot org 2005-11-09 15:19 --- Why do you think this is a bug. The difference between &a[3]-&a[4] better be -1. (where a is an array). -- pinskia at gcc dot gnu dot org changed: What|Removed |Added ---

[Bug c/24756] pointer arithmetic on ia32 uses signed divide

2005-11-09 Thread j3p0uk at hotmail dot com
--- Comment #1 from j3p0uk at hotmail dot com 2005-11-09 14:51 --- Created an attachment (id=10186) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10186&action=view) Test source (.i) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24756