This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/67152] New: [concepts] bogus "partial specialization of âfoo<T>â after instantiation" error
- From: "eric.niebler at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 07 Aug 2015 23:39:36 +0000
- Subject: [Bug c++/67152] New: [concepts] bogus "partial specialization of âfoo<T>â after instantiation" error
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67152
Bug ID: 67152
Summary: [concepts] bogus "partial specialization of âfoo<T>â
after instantiation" error
Product: gcc
Version: c++-concepts
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: eric.niebler at gmail dot com
Target Milestone: ---
The error happens on constrained partial specializations of a template that has
already been instantiated. But the template that got instantiated would fail
the constraint anyway, so the error is complaining about nothing AFAICT.
Consider:
template <class T>
concept bool HasType = requires { typename T::type; };
template<class T>
struct trait {
using type = void;
};
struct has_type { using type = void; };
// Instantiation here
trait<has_type>::type foo() {}
// constrained version here. Type "has_type" would fail this
// constraint so this partial specialization would not have been
// selected.
template<class T>
requires !HasType<T>
struct trait<T> {
using type = void;
};
...yields the following:
test.cpp:17:8: error: partial specialization of âstruct trait<T>â after
instantiation of âstruct trait<has_type>â [-fpermissive]
struct trait<T> {
^
If the partial specialization is the following instead:
template<class T>
struct trait<T*> {
using type = void;
};
then there is no error. It seems to me that for partial specializations, a
constraints failure should be treated similarly to a pattern match failure WRT
such errors.