gcc4.3.0も変?
unsigned foo(int n) { return ~static_cast<unsigned>(-(n + 1)); }
に対して、
.file "foo.cpp" .text .globl _Z3fooi .type _Z3fooi, @function _Z3fooi: .LFB2: pushl %ebp .LCFI0: movl %esp, %ebp .LCFI1: movl 8(%ebp), %eax notl %eax popl %ebp ret .LFE2: .size _Z3fooi, .-_Z3fooi .ident "GCC: (GNU) 4.3.0 20080218 (Red Hat 4.3.0-0.10)" .section .note.GNU-stack,"",@progbits
みたいなコードが吐かれる。
要するにこう解釈されている。
unsigned foo(int n) { return ~reinterpret_cast<unsigned>(n); }
まだ、開発中ってことですかね。