[Bug c/63303] Pointer subtraction is broken when using -fsanitize=undefined
mikulas at artax dot karlin.mff.cuni.cz
gcc-bugzilla@gcc.gnu.org
Fri Sep 19 13:38:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63303
--- Comment #2 from mikulas at artax dot karlin.mff.cuni.cz ---
Jakub Jelinek: I know, but the problem happened in perfectly valid program.
Suppose that you do:
char *p = malloc(0x20000000); - the allocator allocates the array at
0x70000000.
Then, you do:
char *q = p + 0x20000000; /* q is 0x90000000, pointing to the end of the array
*/
long n = q - p; --- this triggers the warning, although it is perfectly valid
operation.
The above case is non-reproducible because it depends on the address returned
from the allocator. I wrote the example code to trigger the warning
deterministically.
More information about the Gcc-bugs
mailing list