https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90652
Bug ID: 90652 Summary: Recursive concept leads to segfault Product: gcc Version: 8.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tobias.bruell at gmail dot com Target Milestone: --- The following program leads to a seg-fault in gcc. Compile with -Wall -Wextra -std=gnu++2a "-fconcepts" It works when using "operator << (os, x)" instead of "os << x" in line 4. ------------------------------------------------------- #include <iostream> void to_json (std::ostream& os, char c) { os << '"' << c << '"'; } template<typename T> concept bool Serializable = requires (T x, std::ostream& os) { { os << x }; }; template<typename T> concept bool ToJson = requires (T x, std::ostream& os) { { to_json (os, x) }; }; template<typename T> requires ToJson<T> && !Serializable<T> std::ostream& operator << (std::ostream& os, T const& x) { to_json (os, x); return os; } int main () { static_assert (Serializable<char>); static_assert (ToJson<char>); std::cout << 'c'; }