From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1218 invoked by alias); 27 Jul 2009 15:06:21 -0000 Received: (qmail 1183 invoked by uid 48); 27 Jul 2009 15:06:04 -0000 Date: Mon, 27 Jul 2009 15:06:00 -0000 Subject: [Bug c++/40874] New: Function object abstraction penalty X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "dave at boost-consulting dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-07/txt/msg02172.txt.bz2 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