Example:
---
int a()
{
static int b;
return ++b;
}
void main()
{
import core.stdc.stdio;
auto aa = [a:a, a:a, a:a, a:a];
foreach (k, v; aa)
printf("%d: %d\n", k, v);
}
---
DMD outputs:
4: 8
3: 7
2: 6
1: 5
GDC outputs:
6: 2
7: 3
5: 1
8: 4
LDC outputs:
7: 8
5: 6
3: 4
1: 2
Each answer makes perfect logical sense when you consider how the literal expression is lowered, but not all can be the correct, intuitive answer.
(NB: GDC output is when running on x86, every other target, e.g: ARM, would evaluate in the same order as DMD x86).
Comment #1 by robert.schadek — 2024-12-13T19:09:59Z