typedef int nl_item; extern char *nl_langinfo (nl_item __item) __attribute__ ((__nothrow__));
char * xtermEnvEncoding(void) { static char *result; if (result == 0) { result = nl_langinfo(1); ; } return result; } Compile the above code with -march=i686 -O2 4.1 generates extra reads to the static result.1282. xtermEnvEncoding: pushl %ebp movl %esp, %ebp subl $8, %esp movl result.1282, %eax testl %eax, %eax je .L6 movl result.1282, %eax <--- this one leave ret .p2align 4,,7 .L6: movl $1, (%esp) call nl_langinfo movl %eax, result.1282 movl result.1282, %eax <-- and this one leave ret 4.0 does not generate those instructions. This is one of the reasons for the code size regression in PR23153. -- Summary: extra reads from static variable Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dann at godzilla dot ics dot uci dot edu CC: gcc-bugs at gcc dot gnu dot org GCC target triplet: i686-pc-linux.-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23488