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

j3p0uk at hotmail dot com gcc-bugzilla@gcc.gnu.org
Thu Nov 10 13:49:00 GMT 2005



------- 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 surprised
that it shows the incorrect result where the result relies upon the sign as it
is performing an unsigned operation.

This is not an invalid bug as there is a real, if very rare, problem shown by
this.

To put it in as simple and direct a form as possible:

Is this a correct answer, given that the 2 operands are the values of 2
pointers pointing to entities of 4 bytes?
0xcceb0000 - 0x24100000 = 0xea36c000

I believe that this is NOT a correct answer, and that is the basis of this bug,
not any other behaviour that is shown by the simple test program.


-- 

j3p0uk at hotmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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



More information about the Gcc-bugs mailing list