https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79366
Bug ID: 79366 Summary: wrong result in cast to unsigned int Product: gcc Version: 7.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: bernd.edlinger at hotmail dot de Target Milestone: --- the following returns an unexpected result: cat test.c double f = -1.0; int main() { int g = (unsigned int)(f); __builtin_printf("%d\n", g); } gcc test.c ./a.out 0 that is only on arm-Linux-gnueabihf other targets return -1 here. Dump of assembler code for function main: 0x000103c0 <+0>: push {r11, lr} 0x000103c4 <+4>: add r11, sp, #4 0x000103c8 <+8>: sub sp, sp, #8 => 0x000103cc <+12>: movw r3, #1440 ; 0x5a0 0x000103d0 <+16>: movt r3, #2 0x000103d4 <+20>: vldr d7, [r3] 0x000103d8 <+24>: vcvt.u32.f64 s15, d7 0x000103dc <+28>: vmov r3, s15 0x000103e0 <+32>: str r3, [r11, #-8] 0x000103e4 <+36>: ldr r1, [r11, #-8] 0x000103e8 <+40>: movw r0, #1140 ; 0x474 0x000103ec <+44>: movt r0, #1 0x000103f0 <+48>: bl 0x102a0 <printf@plt> 0x000103f4 <+52>: mov r3, #0 0x000103f8 <+56>: mov r0, r3 0x000103fc <+60>: sub sp, r11, #4 0x00010400 <+64>: pop {r11, pc}