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; }