[Bug c++/96830] GCC does not complain template-head containing requires clause

2022-07-20 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96830

Jonathan Wakely  changed:

   What|Removed |Added

   Last reconfirmed|2020-08-28 00:00:00 |2022-7-20

--- Comment #3 from Jonathan Wakely  ---
Another examples:

template requires true
struct S
{
  template
friend struct S;
};

S s;



EDG:

"diff.C", line 5: error: requires-clause incompatible with class template "S"
  (declared at line 2)
  friend struct S;
^
  detected during instantiation of class "S [with T=int]" at line 8

1 error detected in the compilation of "diff.C".


Clang:

diff.C:4:3: error: requires clause differs in template redeclaration
  template
  ^
diff.C:8:8: note: in instantiation of template class 'S' requested here
S s;
   ^
diff.C:1:28: note: previous template declaration is here
template requires true
   ^
1 error generated.

[Bug c++/96830] GCC does not complain template-head containing requires clause

2020-08-28 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96830

--- Comment #2 from Jonathan Wakely  ---
G++ still accepts this version, though EDG and Clang reject it:

template concept C = requires { typename T::value_type; };

template
class Foo {
public:
void func();
};

template
void Foo::func()
{}


$ edg --c++20 -c 96830.C
"96830.C", line 10: error: template argument list must match the parameter list
  void Foo::func()
   ^

1 error detected in the compilation of "96830.C".

$ clang++ -std=c++2a -c 96830.C
96830.C:9:10: error: type constraint differs in template redeclaration
template
 ^
96830.C:3:10: note: previous template declaration is here
template
 ^
1 error generated.

[Bug c++/96830] GCC does not complain template-head containing requires clause

2020-08-28 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96830

Jonathan Wakely  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Keywords||accepts-invalid
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2020-08-28

[Bug c++/96830] GCC does not complain template-head containing requires clause

2020-08-28 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96830

--- Comment #1 from Jonathan Wakely  ---
Reduced:

template concept C = requires { typename T::value_type; };

template
requires C
class Foo {
public:
void func();
};

template
void Foo::func()
{}


EDG compiles it without error too. Clang says:

96830.C:10:1: error: requires clause differs in template redeclaration
template
^
96830.C:4:14: note: previous template declaration is here
requires C
 ^
1 error generated.