https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93467
Bug ID: 93467
Summary: [concepts] getting "type constraint differs in
template redeclaration" error after friend declaration
in template
Product: gcc
Version: 9.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: robert.zavalczki at gmail dot com
Target Milestone: ---
I know the C++ standard says:
> "A constrained declaration may only be redeclared using the same syntactic
> form. No diagnostic is required."
However, that specification causes this supposedly correct program to fail:
///////////////////////////////////////
// compile with: g++-9 -fconcepts -std=c++2a
template<typename T> concept True = true;
template<typename U>
struct S1 {
template<True T> friend struct S2; // friend declaration for S2
};
S1<int> s; // instantiate S1
template<True T> struct S2; // another declaration for S2
///////////////////////////////////////
You can test the above snippet on godbolt.org: https://godbolt.org/z/V6uJPe