public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40874]  New: Function object abstraction penalty
@ 2009-07-27 15:06 dave at boost-consulting dot com
  2009-07-27 15:45 ` [Bug tree-optimization/40874] Function object abstraction penalty with inline functions pinskia at gcc dot gnu dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 15+ messages in thread
From: dave at boost-consulting dot com @ 2009-07-27 15:06 UTC (permalink / raw)
  To: gcc-bugs

The following program shows that wrapping a simple class around a function
pointer costs important optimizations.  If you change the #if 1 to #if 0,
you'll see that the call is completely optimized away.  

#if 1
struct pf
{
  inline pf(int(*x)(int)) : x(x) {}

  inline int operator()(int a) const
  {
    return x(a);
  }

  int (*x)(int);
};
#else
typedef int(*pf)(int);
#endif

inline int g(int x) { return x/x - 1; }

int main(int argc, char* argv[])
{
  pf f(g);
  return f(3);
}


-- 
           Summary: Function object abstraction penalty
           Product: gcc
           Version: 4.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dave at boost-consulting dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40874


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

end of thread, other threads:[~2011-05-23 14:57 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-40874-4@http.gcc.gnu.org/bugzilla/>
2011-05-23 14:51 ` [Bug tree-optimization/40874] Function object abstraction penalty with inline functions rguenth at gcc dot gnu.org
2011-05-23 15:09 ` rguenth at gcc dot gnu.org
2009-07-27 15:06 [Bug c++/40874] New: Function object abstraction penalty dave at boost-consulting dot com
2009-07-27 15:45 ` [Bug tree-optimization/40874] Function object abstraction penalty with inline functions pinskia at gcc dot gnu dot org
2009-07-27 16:26 ` dave at boost-consulting dot com
2009-07-27 17:57 ` paolo dot carlini at oracle dot com
2009-07-28 11:23 ` rguenth at gcc dot gnu dot org
2009-07-28 18:42 ` dave at boost-consulting dot com
2009-07-28 19:39 ` paolo dot carlini at oracle dot com
2009-07-28 21:33 ` jamborm at gcc dot gnu dot org
2009-07-29  8:06 ` rguenth at gcc dot gnu dot org
2009-07-29  8:06 ` rguenther at suse dot de
2009-07-29  8:09 ` hubicka at ucw dot cz
2009-07-29  8:12 ` rguenther at suse dot de
2009-07-29 10:17 ` jamborm at gcc dot gnu dot org
2009-07-29 10:57 ` rguenther at suse dot de

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).