https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120949
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The old code was using _GLIBCXX_NODISCARD __attribute__((__always_inline__)) ordering while the new one __attribute__((__always_inline__)) _GLIBCXX_NODISCARD Perhaps only the former works with both compilers? Though __attribute__((always_inline)) [[nodiscard]] constexpr int foo () { return 42; } [[nodiscard]] __attribute__((always_inline)) constexpr int bar () { return 43; } struct S { template <typename T> __attribute__((always_inline)) [[nodiscard]] friend inline int baz () { return 42; } template <typename T> [[nodiscard]] __attribute__((always_inline)) friend inline int qux () { return 43; } }; compiles by both gcc 15.1 and clang trunk.