public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "stefan at bytereef dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/113203] New: __attribute__ ((always_inline)) fails with C99/LTO/-Og. Date: Tue, 02 Jan 2024 16:54:48 +0000 [thread overview] Message-ID: <bug-113203-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113203 Bug ID: 113203 Summary: __attribute__ ((always_inline)) fails with C99/LTO/-Og. Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: stefan at bytereef dot org Target Milestone: --- This is similar to #107931. I'm opening a new issue because there are no indirect function calls and the problem occurs with -std=c99 -flto -Og. foo.c ======================================================== #include <stdbool.h> #include "foo.h" inline __attribute__ ((always_inline)) bool f(int x) { return (x > 2); } ======================================================== foo.h ======================================================== #include <stdbool.h> bool f(int); ======================================================== main.c ======================================================== #include <stdio.h> #include "foo.h" int main(int argc, char *argv[]) { (void)argv; if (f(argc)) { puts("yes"); } else { puts("no"); } return 0; } ======================================================== $ gcc -Wall -Wextra -std=c99 -flto -Og -o main foo.c main.c foo.c: In function ‘main’: foo.c:5:1: error: inlining failed in call to ‘always_inline’ ‘f’: function not considered for inlining 5 | f(int x) | ^ main.c:9:8: note: called from here 9 | if (f(argc)) { | ^ lto-wrapper: fatal error: /home/skrah/gcc/bin/gcc returned 1 exit status compilation terminated. /usr/bin/ld: error: lto-wrapper failed This is extracted from the mpdecimal project that has used C99 and always_inline for a decade without problems. The code was written before the amendment to the always_inline documentation in 2014 and always_inline has consistently produced a speedup of 1-2.5% even with -O3. My questions: 1) Since this is C99, should always_inline work without errors when -std=c99 is active? If not, should -std=c99 reject always_inline? 2) There is a clear demand for something like "really_inline" that ignores the heuristics and just inlines whenever possible without errors or warnings. In practice that is how MSVC __forceinline or clang always_inline behave. Could that be added?
next reply other threads:[~2024-01-02 16:54 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-02 16:54 stefan at bytereef dot org [this message] 2024-01-03 1:57 ` [Bug ipa/113203] " pinskia at gcc dot gnu.org 2024-01-03 2:05 ` pinskia at gcc dot gnu.org 2024-01-03 8:35 ` jakub at gcc dot gnu.org 2024-01-03 16:26 ` stefan at bytereef dot org 2024-01-08 9:16 ` rguenth at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-113203-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).