From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17629 invoked by alias); 13 Feb 2014 14:38:40 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 17612 invoked by uid 48); 13 Feb 2014 14:38:36 -0000 From: "filip.roseen at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/60177] New: Unable to deduce template base of derived class in function template accepting a simple-template-id Date: Thu, 13 Feb 2014 14:38:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: filip.roseen at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-02/txt/msg01233.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60177 Bug ID: 60177 Summary: Unable to deduce template base of derived class in function template accepting a simple-template-id Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: filip.roseen at gmail dot com template struct Base { }; struct Derived : Base { }; template class TT, typename T> void func (TT) { } int main () { func (Derived { }); } - - - - - - - - - - - - - - - - - - - - - - - - - - main.cpp: In function 'int main()': main.cpp:9:20: error: no matching function for call to 'func(Derived)' func (Derived { }); ^ main.cpp:9:20: note: candidate is: main.cpp:6:6: note: template class TT, class T> void func(TT) void func (TT) { } ^ main.cpp:6:6: note: template argument deduction/substitution failed: main.cpp:9:20: note: can't deduce a template for 'TT' from non-template type 'Derived' func (Derived { }); - - - - - - - - - - - - - - - - - - - - - - - - - - gcc rejects the snippet which is a violation of [temp.deduct.call]/4 (`clang` and `msvc` accepts the code). `TT` is a `simple-template-id` and the standard says that if a derived type is passed to such context it should be deduced to a suitable base of that passed type. Correct behavior is that the deduced template parameters for `func (Derived {})` should be `TT = Base, T = void`.