Bug 60177 - Unable to deduce template base of derived class in call to function taking a `simple-template-id`
Summary: Unable to deduce template base of derived class in call to function taking a ...
Status: RESOLVED DUPLICATE of bug 42329
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2014-02-13 14:38 UTC by Filip Roséen
Modified: 2016-01-22 16:34 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.8.2, 4.9.1, 5.0
Last reconfirmed: 2014-12-14 00:00:00


Attachments
testcase.cpp (126 bytes, text/x-c++src)
2014-02-14 10:19 UTC, Filip Roséen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Roséen 2014-02-13 14:38:35 UTC
template<class> struct Base { };

struct Derived : Base<void> { };

template<template<typename> class TT, typename T>
void func (TT<T>) { }

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<template<class> class TT, class T> void func(TT<T>)
 void func (TT<T>) { }
      ^
main.cpp:6:6: note:   template argument deduction/substitution failed:
main.cpp:9:20: note:   can't deduce a template for 'TT<T>' 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<T>` 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`.
Comment 1 Filip Roséen 2014-02-14 10:19:22 UTC
Created attachment 32133 [details]
testcase.cpp
Comment 2 Ville Voutilainen 2014-12-14 14:14:26 UTC
Clang accepts the code.
Comment 3 Ville Voutilainen 2016-01-22 16:34:39 UTC
This looks like a duplicate of a much older PR.

*** This bug has been marked as a duplicate of bug 42329 ***