public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/27527]  New: invalid types produced out of argument deduction (SFINAE bug)
@ 2006-05-09 21:28 sebor at roguewave dot com
  2006-05-10  1:07 ` [Bug c++/27527] " sebor at roguewave dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: sebor at roguewave dot com @ 2006-05-09 21:28 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 9+ messages in thread
[parent not found: <bug-27527-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2011-12-30 13:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-09 21:28 [Bug c++/27527] New: invalid types produced out of argument deduction (SFINAE bug) sebor at roguewave dot com
2006-05-10  1:07 ` [Bug c++/27527] " sebor at roguewave dot com
2006-05-12 16:27 ` sebor at roguewave dot com
2006-05-12 16:31 ` sebor at roguewave dot com
2006-05-26 15:14 ` bangerth at dealii dot org
     [not found] <bug-27527-4@http.gcc.gnu.org/bugzilla/>
2011-09-27 22:20 ` paolo.carlini at oracle dot com
2011-09-28 19:38 ` jason at gcc dot gnu.org
2011-09-28 21:22 ` paolo.carlini at oracle dot com
2011-12-30 13:13 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).