From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22981 invoked by alias); 30 Nov 2012 13:04:15 -0000 Received: (qmail 22517 invoked by uid 48); 30 Nov 2012 13:03:48 -0000 From: "rohan at rohanlean dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/55546] New: Static functions that are fully inlined can end up in the object file Date: Fri, 30 Nov 2012 13:04:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rohan at rohanlean dot de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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: 2012-11/txt/msg02994.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55546 Bug #: 55546 Summary: Static functions that are fully inlined can end up in the object file Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned@gcc.gnu.org ReportedBy: rohan@rohanlean.de Created attachment 28838 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28838 A rather minimal test-case for the bug. If a static function has its address taken in the C code, but due to optimisations the address is never used, then the function can still end up in the object file. I have attached a file to demonstrate the bug. When I compile it with -std=c11 -O3, the resulting executable will contain code for f, even though it is not needed. (As an aside, if you add another function similar to f, and call h with each of them, then gcc will not resolve things so nicely at compile time and also emit code for h.)