[Bug c++/80227] New: [4.6/5/6/7 Regression] SFINAE ambiguity with a pointer to array argument
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Mar 27 21:30:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80227
Bug ID: 80227
Summary: [4.6/5/6/7 Regression] SFINAE ambiguity with a pointer
to array argument
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
Prior to version 4.6, GCC accepted the well-formed program below. Since
r166453 GCC rejects it because it fails to eliminate the second overload of the
foo template from the overload list. The second overload isn't viable because
substituting int for T results in the second argument to the function having an
invalid type (pointer to an array of excessive size).
$ cat y.C && gcc -S -Wall -Wextra -Wpedantic y.C
template <class T>
int foo (T);
template <class T, class U = T [sizeof (T) - 5]>
int foo (T, U* = 0);
int i = foo (123);
y.C:7:17: error: call of overloaded ‘foo(int)’ is ambiguous
int i = foo (123);
^
y.C:2:5: note: candidate: int foo(T) [with T = int]
int foo (T);
^~~
y.C:5:5: note: candidate: int foo(T, U*) [with T = int; U = int [-1]]
int foo (T, U* = 0);
^~~
Conversely, while prior to r166453 GCC would reject the following invalid
program
template <class T>
int foo (T, int (*)[sizeof (T) - 5] = 0);
int i = foo (123);
with
t.C:4:17: error: no matching function for call to ‘foo(int)’
t.C:2:40: note: candidate is: template<class T> int foo(T, int (*)[(sizeof (T)
- 5)])
GCC 4.6 and later accept it.
More information about the Gcc-bugs
mailing list