http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53829
Bug #: 53829 Summary: Trivial static initializers are created for initialization with result of trivial static inline functions Classification: Unclassified Product: gcc Version: 4.7.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: mh+...@glandium.org The most trivial example of the behaviour is this: #include <stdint.h> static inline uint64_t foo() { return 42; } uint64_t f = foo(); G++ generates the following: .file "test.cc" .section .text.startup,"ax",@progbits .p2align 4,,15 .type _GLOBAL__sub_I_f, @function _GLOBAL__sub_I_f: .LFB2: .cfi_startproc movq $42, f(%rip) ret .cfi_endproc .LFE2: .size _GLOBAL__sub_I_f, .-_GLOBAL__sub_I_f .section .init_array,"aw" .align 8 .quad _GLOBAL__sub_I_f .globl f .bss .align 8 .type f, @object .size f, 8 f: .zero 8 .ident "GCC: (Debian 4.7.1-2) 4.7.1" .section .note.GNU-stack,"",@progbits For reference, clang++ generates the following: .file "test.cc" .type f,@object # @f .data .globl f .align 8 f: .quad 42 # 0x2a .size f, 8 .section ".note.GNU-stack","",@progbits There are cases where g++ is able to generate code like clang++, but I can't find one just now.