https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124961
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think CTAD reflection support has been fixed yesterday with r16-8765 PR124706
change.
Your testcase is now rejected with
pr124961.C:6:10: error: class template argument deduction failed:
6 | [:x:] a{0}; // error: expected unqualified-id before '[:' token
| ^
pr124961.C:6:10: error: no matching function for call to ‘A(int)’
• there are 3 candidates
• candidate 1: ‘template<class T> A() -> A<T>’
pr124961.C:2:8:
2 | struct A { int x; };
| ^
• candidate expects 0 arguments, 1 provided
• candidate 2: ‘template<class T> A(A<T>) -> A<T>’
• template argument deduction/substitution failed:
• mismatched types ‘A<T>’ and ‘int’
pr124961.C:6:10:
6 | [:x:] a{0}; // error: expected unqualified-id before '[:'
token
| ^
• candidate 3: ‘template<class T> A(int) -> A<T>’
pr124961.C:2:8:
2 | struct A { int x; };
| ^
• template argument deduction/substitution failed:
• couldn’t deduce template parameter ‘T’
pr124961.C:6:10:
6 | [:x:] a{0}; // error: expected unqualified-id before '[:'
token
| ^
pr124961.C: In function ‘auto test()’:
pr124961.C:9:27: error: class template argument deduction failed:
9 | return typename[:x:]{0}; // error: expected primary-expression
before 'typename'
| ^
pr124961.C:9:27: error: no matching function for call to ‘A(int)’
• there are 3 candidates
• candidate 1: ‘template<class T> A() -> A<T>’
pr124961.C:2:8:
2 | struct A { int x; };
| ^
• candidate expects 0 arguments, 1 provided
• candidate 2: ‘template<class T> A(A<T>) -> A<T>’
• template argument deduction/substitution failed:
• mismatched types ‘A<T>’ and ‘int’
pr124961.C:9:27:
9 | return typename[:x:]{0}; // error: expected
primary-expression before 'typename'
| ^
• candidate 3: ‘template<class T> A(int) -> A<T>’
pr124961.C:2:8:
2 | struct A { int x; };
| ^
• template argument deduction/substitution failed:
• couldn’t deduce template parameter ‘T’
pr124961.C:9:27:
9 | return typename[:x:]{0}; // error: expected
primary-expression before 'typename'
| ^
but isn't that correct?
If you change
-struct A { int x; };
+struct A { T x; };
then the testcase is accepted.