https://bugs.llvm.org/show_bug.cgi?id=49053
Bug ID: 49053
Summary: Variable declared in if init statement sneaks into
lambda expression
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++17
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
The following code fails to compile with clang:
```
int main() {
if (auto foo = [] { int foo = 42; return true; }()) {}
}
```
saying
#1 with x86-64 clang (trunk)
<source>:2:29: error: redefinition of 'foo' with a different type: 'int' vs
'auto'
if (auto foo = [] { int foo = 42; return true; }()) {}
^
<source>:2:14: note: previous definition is here
if (auto foo = [] { int foo = 42; return true; }()) {}
^
1 error generated.
ASM generation compiler returned: 1
<source>:2:29: error: redefinition of 'foo' with a different type: 'int' vs
'auto'
if (auto foo = [] { int foo = 42; return true; }()) {}
^
<source>:2:14: note: previous definition is here
if (auto foo = [] { int foo = 42; return true; }()) {}
^
1 error generated.
Execution build compiler returned: 1
```
gcc accepts this code, and this seems right. The lambda expression does not
capture foo.
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs