https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121916
Bug ID: 121916
Summary: GCC rejects variable/function template declarations of
fully qualified-ids with parentheses
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gulackeg at gmail dot com
Target Milestone: ---
Test code:
// https://godbolt.org/z/soaqjcW1W
struct S {};
namespace N {
template <int> S F() { return {}; }
} // namespace N
template S(::N::F<0>)(); // OK
// - Clang/MSVC/EDG: OK
// - GCC:
// - error: 'template<int <anonymous> > S N::F()' is not a type
// - error: expected constructor, destructor, or type conversion
// before '(' token
template <> S(::N::F<1>)() { return {}; }
namespace N {
template <class> S V = {};
}
// - Clang/EDG: OK
// - GCC:
// - error: 'template<class> S N::V< <template-parameter-1-1> >' is
// not a type
// - error: expected constructor, destructor, or type conversion
// before '(' token
// - MSVC:
// - error C2908: explicit specialization; 'N::V<char>' has already
// been instantiated
// - note: see previous definition of 'N::V<char>'
template <> S(::N::V<char>) = {};
// - Clang/MSVC/EDG: OK
// - GCC:
// - warning: unnecessary parentheses in declaration of 'V'
// [-Wparentheses]
// - note: remove parentheses
template S(::N::V<int>);
// - Clang/MSVC/EDG: OK
// - GCC:
// - error: 'template<class> S N::V< <template-parameter-1-1> >' is
// not a type
// - error: expected constructor, destructor, or type conversion
// before '(' token
template <class T> S(::N::V<T *>) = {};