https://llvm.org/bugs/show_bug.cgi?id=24174
Bug ID: 24174
Summary: Use of parameter within template parameter of default
argument
Product: libc++
Version: 3.7
Hardware: PC
OS: Windows XP
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Clang compiles the following code on trunk:
template<int>
constexpr int variable{};
int main() {
auto f = [] (auto x, int = variable<x>) {};
f(0, 0);
}
Even though the default argument is never used the code should still fail since
parameters are not allowed anywhere outside an unevaluated operand in a
function declaration.
When the second argument is used (i.e f(0)) or we replace auto with int we get
an error:
error: non-type template argument is not a constant expression
auto f = [] (auto x, int = variable<x>) {};
^
note: in instantiation of default function argument expression for
'operator()<int>' required here
f(0);
^
note: read of non-const variable 'x' is not allowed in a constant expression
auto f = [] (auto x, int = variable<x>) {};
But this error should read more or less like the following:
error: default argument references parameter 'x'
It seems clang does not perform the same error checking when parameter names
are used as non-type template arguments.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs