https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103678
Bug ID: 103678
Summary: [concepts] Constrained partial specialization of
dependent template conflicts with unconstrained
partial specialization
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: matthewjbarichello at gmail dot com
Target Milestone: ---
Reduced example:
template<typename>
struct A {
template<typename...>
struct B;
};
template<typename A_t>
template<typename B_t>
struct A<A_t>::B<B_t> {};
template<typename A_t>
template<typename B_t>
requires requires {
typename B_t;
}
struct A<A_t>::B<B_t> {};
Cmdline:
g++ -std=c++20 example.cpp
Expected behaviour:
Example compiles. The partial specialization defined on line 16 should be a
distinct partial specialization as it is more constrained than the base
template and the partial specialization on line 9.
Actual behaviour:
Example does not compile and compiler emits the following diagnostic:
<source>:16:16: error: redefinition of 'struct A< <template-parameter-1-1>
>::B<B_t>'
16 | struct A<A_t>::B<B_t> {};
| ^~~~~~
<source>:9:16: note: previous definition of 'struct A<
<template-parameter-1-1> >::B<B_t>'
9 | struct A<A_t>::B<B_t> {};
| ^~~~~~
Affected versions:
GCC 10 through 12.
Notes:
- Compiles fine on Clang and MSVC.
- Only seems to happen for partially specialized dependent templates, as the
following code compiles without an error:
template<typename...>
struct A;
template<typename A_t>
struct A<A_t> {};
template<typename A_t>
requires requires {
typename A_t;
}
struct A<A_t> {};