[LLVMbugs] [Bug 24076] New: Clang compiles a substitution failed template with default parameter

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jul 9 11:21:40 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24076

            Bug ID: 24076
           Summary: Clang compiles a substitution failed template with
                    default parameter
           Product: clang
           Version: 3.6
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: antoshkka at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

If substitution of a single matching function failed, clang does not fail
compilation:


template <class ...>
using void_t = void;

template <class T>
T declval();

template <class T, class = void_t< decltype(declval<T>() + 1) > >
void foo(T) {}

struct s{};

int main() {
    foo(s{}); // must fail compilation, but does not
}



For example GCC fails with the following messages:

main.cpp:13:12: error: no matching function for call to 'foo(s)'
     foo(s{}); // must fail compilation, but does not
            ^
main.cpp:8:6: note: candidate: template<class T, class> void foo(T)
 void foo(T) {}
      ^
main.cpp:8:6: note:   template argument deduction/substitution failed:
main.cpp:7:58: error: no match for 'operator+' (operand types are 's' and
'int')
 template <class T, class = void_t< decltype(declval<T>() + 1) > >
                                                          ^


Exactly the same problem for classes:
template <class ...>
using void_t = void;

template <class T>
T declval();

template <class T, class = void_t< decltype(declval<T>() + 1) > >
struct foo {
    foo(T) {};   
};

struct s{};

int main() {
    foo<s>(s{}); // must fail compilation, but does not
}

-- 
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/20150709/712fb3ce/attachment.html>


More information about the llvm-bugs mailing list