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: unassignedclangb...@nondot.org
Reporter: danijel.zl...@gmail.com
CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
llvm-bugs@lists.llvm.org, richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs