This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/36959] New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Jul 2008 23:33:37 -0000
- Subject: [Bug c++/36959] New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Take:
static inline int *fromSlotB(void)
{
static int shuf_BZZZ = 1;
return &shuf_BZZZ;
}
int main(void)
{
return (int)fromSlotB();
}
--- CUT ---
At -O2, fromSlotB is still being emitted even though it is unused.
It is being marked in cxx_callgraph_analyze_expr:
else if (DECL_CONTEXT (t)
&& TREE_CODE (DECL_CONTEXT (t)) == FUNCTION_DECL)
/* If we need a static variable in a function, then we
need the containing function. */
mark_decl_referenced (DECL_CONTEXT (t));
For -frepo this might be true but I don't think this is true in general.
This regression was introduced to do unit-at-a-time always for C++:
http://gcc.gnu.org/ml/gcc-patches/2004-07/msg02615.html
--
Summary: [4.2/4.3/4.4 Regression] C++ front-end causing a static
inline function to be emitted
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36959