The following code used to compile with DMD versions between 2.086.1 to 2.100.2, but starting from DMD 2.102 it fails. I haven't bisected it further, but I assume this is a bug:
```
extern(C++)
struct X {
static foreach(i; iota(0, 3)) {
}
}
```
Compilation fails with the message:
```
onlineapp.d(5): Error: function `onlineapp.X.__lambda2` cannot return type `int[]` because its linkage is `extern(C++)`
onlineapp.d(5): slices are specific to D and do not have a counterpart representation in C++
```
I'm using patterns like this to generate a lot of struct members that follow simple patterns using mixins. I assume that the cause of the error is that the iota() is rejected based on the extern(C++) for the context, even though the evaluation is strictly CTFE due to the static foreach.
Comment #1 by robert.schadek — 2024-12-13T19:33:23Z