[Bug c++/53829] New: Trivial static initializers are created for initialization with result of trivial static inline functions
mh+gcc at glandium dot org
gcc-bugzilla@gcc.gnu.org
Mon Jul 2 06:26:00 GMT 2012
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: unassigned@gcc.gnu.org
ReportedBy: mh+gcc@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.
More information about the Gcc-bugs
mailing list