public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/114784] [14 Regression] Inlining fails for always_inline inheriting constructor
Date: Fri, 19 Apr 2024 20:21:24 +0000	[thread overview]
Message-ID: <bug-114784-4-ez19yF3JB8@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114784-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114784

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |hubicka at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-04-19
   Target Milestone|---                         |14.0

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r14-2149-gabdf0b6cdff5783b97f35ad61ae31433f0569dfd
That said, if you just fix the warning (i.e. remove the UB from serenity_main
if it would ever return), then it compiles fine.  Say by adding return 0;
statement.
But adding [[gnu::cold]] attribute to serenity_main makes it error again.

Honza, I thought always_inline should have precedence over decisions if it
inlines into cold code or not etc.?
Or maybe always_inline attribute is copied over to the inheriting constructors
but DECL_DISREGARD_INLINE_LIMITS is not?

template <typename Base>
struct VariantConstructors {
  __attribute__((always_inline)) VariantConstructors(int t) {
    base().set(t, {});
  }
  __attribute__((always_inline)) VariantConstructors(long long t) {
    base().set(t, {});
  }
  Base base();
};

struct Variant : VariantConstructors<Variant> {
  using VariantConstructors<Variant>::VariantConstructors;

  __attribute__((always_inline)) Variant(long long v) : VariantConstructors(v)
{}

  template <typename T> void set(T &&, int);
  char m_data;
};

struct ErrorOr {
  ErrorOr(int v) : a(v) { }
  ErrorOr(long long v) : a(v) { }
  Variant a;
};
static ErrorOr run() {
  ErrorOr x(0); // compiles with this line removed
  ErrorOr y(0LL);
  return 0;
}
[[gnu::cold]] int serenity_main() {
    run();
    return 0;
}

  parent reply	other threads:[~2024-04-19 20:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19 20:05 [Bug ipa/114784] New: " dani at danielbertalan dot dev
2024-04-19 20:08 ` [Bug ipa/114784] " dani at danielbertalan dot dev
2024-04-19 20:21 ` jakub at gcc dot gnu.org [this message]
2024-04-19 20:42 ` jakub at gcc dot gnu.org
2024-04-19 21:07 ` jakub at gcc dot gnu.org
2024-04-19 22:00 ` dani at danielbertalan dot dev
2024-04-22 11:14 ` jakub at gcc dot gnu.org
2024-04-23  6:39 ` cvs-commit at gcc dot gnu.org
2024-04-23  6:40 ` jakub 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-114784-4-ez19yF3JB8@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: link
Be 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).