[LLVMbugs] [Bug 21405] New: invalid function template argument deduction when used with alias template

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Oct 28 09:55:01 PDT 2014


            Bug ID: 21405
           Summary: invalid function template argument deduction when used
                    with alias template
           Product: clang
           Version: 3.4
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: filip.roseen at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 13258
  --> http://llvm.org/bugs/attachment.cgi?id=13258&action=edit

template<class T>
using universal_ref = T&&;

template<class T>
void func (universal_ref<T> x) { }

int main () {
  int   a;
  func (a);


`clang` inaccurately rejects the above snippet with the following

  note: candidate function [with T = int] not viable: no
  known conversion from 'int' to 'universal_ref<int>' (aka
  'int &&') for 1st argument void func (universal_ref<T>) {

All of `gcc`, `vc++`, and `icc`, correctly accepts it and effectively
instantiates `func<int&>`.



  > If `P` is a cv-qualified type, the top level cv-qualifiers of
  > `P`'s type are ignored for type deduction. If `P` is a reference
  > type, the type referred to by `P` is used for type deduction. If
  > `P` is an rvalue reference to a cv-unqualified template parameter
  > and the argument is an lvalue, the type "lvalue reference to A" is
  > used in place for `A` for type deduction.


  > When a template-id refers to the specialization of an alias
  > template, it is equivalent to the associated type obtained by
  > substitution of its template-arguments for the template-parameters
  > in the type-id of the alias template.


You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141028/543f9339/attachment.html>

More information about the llvm-bugs mailing list