[Bug c++/89237] Partial specialization incorrectly marked as ambiguous
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Feb 7 20:19:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89237
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2019-02-07
CC| |msebor at gcc dot gnu.org
Ever confirmed|0 |1
Known to fail| |6.4.0, 7.3.0, 8.2.0, 9.0
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed with the test case below (please be sure to include the compiler
output). Not a regression.
Clang rejects it with the same error in C++ 98 mode so I wonder if the GCC
error is because of some yet-to-be implemented language change.
$ cat pr89237.C && /build/gcc-svn/gcc/xgcc -B /build/gcc-svn/gcc -S -Wall
pr89237.C
template <bool B, typename T = void> struct enable_if {};
template <typename T> struct enable_if<true, T> { typedef T type; };
template <typename T, typename = void> struct S;
template <typename T> struct S<T, typename enable_if<sizeof(T)>::type> {};
template <typename T> struct S<T *> {};
int main() { S<int *> s; }
pr89237.C: In function ‘int main()’:
pr89237.C:8:23: error: ambiguous template instantiation for ‘struct S<int*>’
8 | int main() { S<int *> s; }
| ^
pr89237.C:5:30: note: candidates are: ‘template<class T> struct S<T, typename
enable_if<(sizeof (T) != 0)>::type> [with T = int*]’
5 | template <typename T> struct S<T, typename enable_if<sizeof(T)>::type>
{};
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pr89237.C:6:30: note: ‘template<class T> struct S<T*> [with T =
int]’
6 | template <typename T> struct S<T *> {};
| ^~~~~~
pr89237.C:8:23: error: aggregate ‘S<int*> s’ has incomplete type and cannot be
defined
8 | int main() { S<int *> s; }
| ^
More information about the Gcc-bugs
mailing list