https://bugs.llvm.org/show_bug.cgi?id=46648
Bug ID: 46648
Summary: template lambda with default value can't be called if
passing argument type doesn't match default value type
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++2a
Assignee: unassignedclangb...@nondot.org
Reporter: iurii.shty...@gmail.com
CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk
interactive: https://godbolt.org/z/mM9hY8
code:
_________________________
#include <string>
using std::literals::operator""s;
int main(){
auto error_lambda = []<class T = int>(T def = 1) -> T {
return def;
};
error_lambda(1);
error_lambda("error"s);
//but it works if default value = 0
auto good_lambda = []<class T = int>(T def = 0) -> T {
return def;
};
good_lambda(1);
good_lambda("good"s);
}
_________________________
output:
<source>:10:5: error: no matching function for call to object of type '(lambda
at <source>:5:25)'
error_lambda("error"s);
^~~~~~~~~~~~
<source>:5:25: note: candidate template ignored: substitution failure [with T =
std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char>>]: no viable conversion from 'int' to
'std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char>>'
auto error_lambda = []<class T = int>(T def = 1) -> T {
^ ~~~
1 error generated.
Compiler returned: 1
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs