[llvm-bugs] [Bug 46242] New: Compiler error when using lambda inside if initializer
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jun 8 07:11:54 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46242
Bug ID: 46242
Summary: Compiler error when using lambda inside if initializer
Product: clang
Version: 10.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++17
Assignee: unassignedclangbugs at nondot.org
Reporter: danijel.zlaus at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
Hi, I have discovered a slight bug (?). The following code does not compile
when the lambda is used inside an if initializer
//Compiler error, error: redefinition of 'foo'
if(int foo = [&](){
int foo = 0;
return foo;
}();
foo)
{
...
}
While if the same code is used outside of an initilizer statement it works as
expected.
int foo = [&](){
int foo = 0;
return foo;
}();
if(foo)
{
return 1;
}
GCC compiles both cases fine, so I suspect this is a bug in the clang frontend.
Example on compiler explorer here:
https://godbolt.org/z/hcUZrx
--
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/20200608/ec15b94b/attachment-0001.html>
More information about the llvm-bugs
mailing list