https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101782
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rejects-valid Assignee|redi at gcc dot gnu.org |unassigned at gcc dot gnu.org Status|ASSIGNED |NEW Component|testsuite |c++ --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- This is a C++ FE bug. This valid C++20 code: template<typename T> concept foo = true; template<typename T> requires foo<T> [[nodiscard]] int bar(T) { return 1; } is rejected with the -fconcepts-ts flag (as both C++20 and C++17): conc.C:4:1: error: two consecutive ‘[’ shall only introduce an attribute before ‘[’ token 4 | [[nodiscard]] | ^ For C++17 mode, -fconcepts-ts defines __cpp_concepts=201507L so we could use that to suppress the [[nodiscard]] attributes when the flag is given. But we can't detect it for C++20 mode (which is when the testsuite errors happen) because C++20 defines __cpp_concepts=201907L and -fconcepts-ts doesn't change that. So I'm not sure what we can do, other than not apply the attribute to constrained functions with a requires-clause.