aligned struct field weirdness

Steven Schveighoffer schveiguy at gmail.com
Tue Jun 18 20:05:52 UTC 2024


On Tuesday, 18 June 2024 at 09:10:28 UTC, realhet wrote:
> I tried to narrow the problem, but I wasn't able, but I guess 
> I've found another solution: There is a part in my framework 
> which works with LDC2 1.28, but that's 'illegal' with later 
> versions.

Oh yeah. That is many versions ago! Released in 2021.

> That's why I'm stuck in the past, but now it adds more 
> motivation to catch up with the latest version.

Another motivation -- even if you found this was a bug and it is 
still in the latest compiler, the fix will go into the *latest 
compiler*, not the one that works with your code!

> That part declares an enum, whose members have UDA's pointing 
> to the enum's members.
> With 2 step parsing it is valid, but later compiler versions 
> don't like this.
> It's a quite big state machine graph, I have to refactor this 
> to eliminate this self-referencing to catch up with the latest 
> compiler.

Hm... a possibility is to change the UDAs to strings, and then 
post-process the strings into the actual members using 
`__traits(getMember, State, name)`

So e.g.:

```d
enum State {
    @"state2" state1,
    @"state1" state2
}
```

-Steve


More information about the Digitalmars-d-learn mailing list