[Bug d/109108] New: d: Undefined reference to lambda in private enum
ibuclaw at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Mar 12 14:52:31 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109108
Bug ID: 109108
Summary: d: Undefined reference to lambda in private enum
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: d
Assignee: ibuclaw at gdcproject dot org
Reporter: ibuclaw at gcc dot gnu.org
Target Milestone: ---
Similar to pr108055. Lambdas should be emitted in every module they are
referenced from.
```
import other;
void main()
{
auto a = callFun(1);
}
```
```
private enum int function(ref int)[] funs =
[
0: (ref idx) => 0,
1: (ref idx) => 1,
];
int callFun(I)(I idx)
{
return funs[idx](idx);
}
```
Only compiling the "main" module results in linker errors.
---
$ gdc test.d -Wl,--demangle=dlang
/usr/x86_64-pc-linux-gnu/bin/ld: /tmp/ccDW8iNw.o: in function
`other.callFun!(int).callFun(int)':
test.d:(.text+0x4b): undefined reference to
`other.__lambda4!(int).__lambda4(ref int)'
test.d:(.text+0x56): undefined reference to
`other.__lambda5!(int).__lambda5(ref int)'
collect2: error: ld returned 1 exit status
More information about the Gcc-bugs
mailing list