https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115603
Bug ID: 115603 Summary: [concepts] differing declaration and definition do not give error Product: gcc Version: 14.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ispavlick at gmail dot com Target Milestone: --- #include <vector> #include <functional> #include <iostream> template <typename T> requires std::is_pointer_v<T> using stored_not_null = T; template <int column_cnt> class Table; template <int column_cnt> class Data_with_refresh { Table<column_cnt> *m_table; public: // Declaration does not match with defenition. // stored_not_null<Table<column_cnt>> violates constraint, // defeition - does not Data_with_refresh(stored_not_null<Table<column_cnt>> *table); void fn(); }; template <int column_cnt> using enter_cb = std::function<void(Data_with_refresh<column_cnt> d)>; template <int column_cnt> class Table { enter_cb<column_cnt> m_entercb; public: Table(enter_cb<column_cnt> entercb) { m_entercb = std::move(entercb); m_entercb(this); } void refresh() {std::cout << "tick" << std::endl;} }; // Defenition is different, and does not violates contstraint template <int column_cnt> Data_with_refresh<column_cnt>::Data_with_refresh( stored_not_null<Table<column_cnt> *> table) : m_table(table) {} template <int column_cnt> void Data_with_refresh<column_cnt>::fn() { m_table->refresh(); } int main() { Table<3> tt([](Data_with_refresh<3> dd) { dd.fn(); }); } gcc compiles this without errors and warnings, clang gives compile time error