| Issue |
233811
|
| Summary |
Lambda in a default argument shouldn't be able to use the function parameters
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
TabbySqui
|
The test:
```
int t (int g, int h = [](){return g;}()) {return g+h; }
int main() {
return t(8);
}
```
https://godbolt.org/z/zaWx75YGj
Compilation produces 'g' global variable
<details>
<summary>llvm-ir</summary>
```
@_ZZ1tiiE1g = internal global i32 0, align 4
; Function Attrs: mustprogress noinline nounwind optnone uwtable
define dso_local noundef i32 @_Z1tii(i32 noundef %0, i32 noundef %1) #0 !dbg !9 {
%3 = alloca i32, align 4
%4 = alloca i32, align 4
store i32 %0, ptr %3, align 4
#dbg_declare(ptr %3, !15, !DIExpression(), !16)
store i32 %1, ptr %4, align 4
#dbg_declare(ptr %4, !17, !DIExpression(), !18)
%5 = load i32, ptr %3, align 4, !dbg !19
%6 = load i32, ptr %4, align 4, !dbg !20
%7 = add nsw i32 %5, %6, !dbg !21
ret i32 %7, !dbg !22
}
; Function Attrs: mustprogress noinline norecurse optnone uwtable
define dso_local noundef i32 @main() #1 !dbg !23 {
%1 = alloca i32, align 4
%2 = alloca %class.anon, align 1
store i32 0, ptr %1, align 4
%3 = call noundef i32 @"_ZNK3$_0clEv"(ptr noundef nonnull align 1 dereferenceable(1) %2), !dbg !26
%4 = call noundef i32 @_Z1tii(i32 noundef 8, i32 noundef %3), !dbg !26
ret i32 %4, !dbg !27
}
; Function Attrs: mustprogress noinline nounwind optnone uwtable
define internal noundef i32 @"_ZNK3$_0clEv"(ptr noundef nonnull align 1 dereferenceable(1) %0) #0 align 2 !dbg !28 {
%2 = alloca ptr, align 8
store ptr %0, ptr %2, align 8
#dbg_declare(ptr %2, !36, !DIExpression(), !38)
%3 = load ptr, ptr %2, align 8
%4 = load i32, ptr @_ZZ1tiiE1g, align 4, !dbg !39
ret i32 %4, !dbg !40
}
```
</details>
Starts with clang-19.1.0 till now
<details>
<summary>clang-trunk</summary>
clang version 24.0.0git (https://github.com/llvm/llvm-project.git 446eb2c13b4e8c7b5136f764c51637c345dfc695)
</details/
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs