This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/31785] New: RFE: Possible to avoid emitting ctor sections for trivial constructors of static objects ?
- From: "caolanm at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 May 2007 12:37:59 -0000
- Subject: [Bug c++/31785] New: RFE: Possible to avoid emitting ctor sections for trivial constructors of static objects ?
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
i.e. there are global keyed constructors emitted for global objects which have
trivial constructors which just zero the contents of the object
e.g.
gcc -Os foo.cxx of
---
static void * myPointer1(0);
void * myFunction1() { return myPointer1; }
struct MyStruct {
void * pointer;
};
static MyStruct myPointer2;
---
and readelf -S foo.o | grep ctor
shows nothing, while...
gcc -Os foo.cxx of
---
struct MyOtherStruct {
void * pointer;
MyOtherStruct(): pointer(0) {}
};
static MyOtherStruct myPointer3;
---
gives an readelf -S foo.o | grep ctor
[ 5] .ctors PROGBITS 0000000000000000 00000070
[ 6] .rela.ctors RELA 0000000000000000 00000700
and
nm foo.o | grep GLOBAL | c++filt | grep keyed | c++filt
000000000000001c t global constructors keyed to foo.cxx_00000000_A20C6F19
It'd be neat if the global static MyOtherStruct myPointer3 ctor could be
optimized away.
--
Summary: RFE: Possible to avoid emitting ctor sections for
trivial constructors of static objects ?
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: caolanm at redhat dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31785