This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/27527] New: invalid types produced out of argument deduction (SFINAE bug)
- From: "sebor at roguewave dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 May 2006 21:28:17 -0000
- Subject: [Bug c++/27527] New: invalid types produced out of argument deduction (SFINAE bug)
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The program below fails to compile with gcc 4.1.0. According to 14.8.2, p2,
template argument deduction must fail if it would result in an invalid type.
Bullet 1 in the same paragraph specifically mentions "attempting to create an
array with an element type that is void" as one possible reason for such a
failure. Thus in the program below the first overload of foo must not be
considered a candidate for overload resolution since doing so would result an
invalid type (A<int, void>::X where X is an array of void).
See also bug 27402.
$ cat t.cpp && gcc t.cpp
template <class, class U = void> struct A { typedef U X [1]; };
template <class T> struct B { typedef T Y; };
template <class T>
A<T> foo (T) { return A<T>(); }
template <class T>
B<T> foo (T) { return B<T>(); }
int main ()
{
foo (0);
}
t.cpp: In function 'int main()':
t.cpp:12: error: call of overloaded 'foo(int)' is ambiguous
t.cpp:5: note: candidates are: A<T, void> foo(T) [with T = int]
t.cpp:8: note: B<T> foo(T) [with T = int]
--
Summary: invalid types produced out of argument deduction (SFINAE
bug)
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sebor at roguewave dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27527