public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/36959]  New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted
@ 2008-07-28 23:34 pinskia at gcc dot gnu dot org
  2008-07-28 23:34 ` [Bug c++/36959] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-07-28 23:34 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-11-03 23:50 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-28 23:34 [Bug c++/36959] New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted pinskia at gcc dot gnu dot org
2008-07-28 23:34 ` [Bug c++/36959] " pinskia at gcc dot gnu dot org
2008-08-04 18:41 ` rguenth at gcc dot gnu dot org
2008-09-20 15:28 ` rguenth at gcc dot gnu dot org
2008-09-20 18:36   ` Andrew Thomas Pinski
2008-09-20 18:38 ` pinskia at gmail dot com
2008-09-20 22:00 ` mmitchel at gcc dot gnu dot org
2009-03-31 20:57 ` [Bug c++/36959] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
2009-05-22  0:32 ` pinskia at gcc dot gnu dot org
2009-08-04 12:42 ` rguenth at gcc dot gnu dot org
2009-11-03 22:26 ` jason at gcc dot gnu dot org
2009-11-03 23:03 ` jason at gcc dot gnu dot org
2009-11-03 23:49 ` jason at gcc dot gnu dot org
2009-11-03 23:50 ` jason at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).