http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47239
Summary: (int)&func & 3 is always optimized to 0 on some targets Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: kkoj...@gcc.gnu.org Targets like arm, hppa and sh64 use the lower bits of the address of functions for special purposes. Even on those targets, ---- extern void plabel32_function (void); int is_plabel32 (void) { return ((unsigned long) &plabel32_function & 3); } ---- which was the test case of PR 35705, is wrongly compiled with -O2. It seems that tree-bit-ccp optimization evaluates the expression ((unsigned long) &plabel32_function & 3) to zero always. With -fno-tree-bit-ccp, the result looks OK. For example, arm-eabi compiler outputs mov r0, #0 bx lr with -O2 and ldr r0, .L2 and r0, r0, #3 bx lr .L3: .align 2 .L2: .word plabel32_function with -O2 -fno-tree-bit-ccp. I've got similar results for hppa and sh64 compilers.