https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114504
Bug ID: 114504
Summary: Non-structural type accepted as non-type template
parameter type
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ted at lyncon dot se
Target Milestone: ---
gcc accepts `NonStructuralType` as a non-type template parameter type below:
```
struct StructuralType1 {
constexpr StructuralType1(int A) : a(A) {}
int a;
};
struct NonStructuralType {
constexpr NonStructuralType(int A) : a(A) {}
private:
int a;
};
template <typename T>
concept is_structural = requires { []<T t> {}; };
static_assert(is_structural<StructuralType1>,
"BUG! StructuralType1 is not structural");
static_assert(!is_structural<NonStructuralType>,
"BUG! NontStructuralType is structural");
int main() {}
```
I was expecting `[]<T t>{}` to fail in the concept. The program compiles with
clang++, icx and MSVC.