[llvm-bugs] [Bug 34005] New: Compiler confused when compiling template variable initialized by lambda-expression with default parameter.
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jul 31 07:57:22 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34005
Bug ID: 34005
Summary: Compiler confused when compiling template variable
initialized by lambda-expression with default
parameter.
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: shirayama.kazatsuyu at gmail.com
CC: llvm-bugs at lists.llvm.org
The code below fail to be compile.
// prog.cc
template<int> struct X {};
template<int n> constexpr void f(X<n>) {}
template<typename> constexpr int v = [](int r = 0l) constexpr { return r; }();
int main() {
f<v<int>>(X<0>());
}
$ clang++ -std=c++1z prog.cc
prog.cc:6:5: error: no matching function for call to 'f'
f<v<int>>(X<0>());
^~~~~~~~~
prog.cc:2:32: note: candidate function not viable: no known conversion from
'X<...>' to 'X<...>' for 1st argument
template<int n> constexpr void f(X<n>) {}
^
1 error generated.
I think v<T> is always 0, so f<v<int>>(X<0>()) should match f<0>(X<0>);
And if lambda's default parameter type is int,
template<typename> constexpr int v = [](int r = 0) constexpr { return r; }();
There are no errors.
This link is the result executed by wandbox.
https://wandbox.org/permlink/yjKqrYKQyl2YZ6PO
--
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/20170731/3723d8b3/attachment.html>
More information about the llvm-bugs
mailing list