[forwarded from http://bugs.debian.org/440545]
seen with 4.2 branch 20070902, works with 4,1 branch and trunk Matthias Output from attached program, if compiled with optimization level -O2: >From 0 to 2: 0 - In: -1, -1 (0xffffffffffffffff), Out: -1 1 - In: 0, 0 (0xffffffffffffffff), Out: 0 2 - In: 1, 1 (0xffffffffffffffff), Out: 1 >From 1 to 3: 1 - In: 0, 0 ((nil)), Out: 0 2 - In: 1, 1 (0x1), Out: 1 3 - In: 2, 2 (0x2), Out: 2 Should be >From 0 to 2: 0 - In: -1, -1 (0xffffffffffffffff), Out: -1 1 - In: 0, 0 ((nil)), Out: 0 2 - In: 1, 1 (0x1), Out: 1 >From 1 to 3: 1 - In: 0, 0 ((nil)), Out: 0 2 - In: 1, 1 (0x1), Out: 1 3 - In: 2, 2 (0x2), Out: 2 #include <assert.h> #include <stdio.h> #include <stdlib.h> int main() { int i = 0; printf("From 0 to 2:\n"); for (i = 0; i < 3; i++) { int iin = i - 1; signed long lin = iin; void *pin = (void *) lin; signed long iout = (signed long) pin; printf(" %d - In: %d, %ld (%p), Out: %ld\n", i, iin, lin, pin, iout); } printf("From 1 to 3:\n"); for (i = 1; i < 4; i++) { int iin = i - 1; signed long lin = iin; void *pin = (void *) lin; signed long iout = (signed long) pin; printf(" %d - In: %d, %ld (%p), Out: %ld\n", i, iin, lin, pin, iout); } return EXIT_SUCCESS; } -- Summary: [4.2 regression] miscompilation casting signed long to void* Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: debian-gcc at lists dot debian dot org GCC target triplet: x64_86-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33381