The following testcase is miscompiled: #include <stdio.h> double foo() { return 1.0; } static struct S { S(); } s; static const double Y = foo()+2.0; S::S() { printf("%f\n", Y); } int main() { printf("%f\n", Y); } Both printfs should print 3 based on Mark's insight in Comment #22 of bug 21089. -Chris
Note that this could be handled in a straight-forward way with init priorities.
Confirmed, not a regression.
Hmm, ICC gets it wrong too, maybe there is a misunderstanding somewhere.
This is not a bug; Mark's comment in bug 21089 had to do with the fact that [basic.start.init] says that static initialization happens before dynamic initialization. Using foo() in Y's initializer makes Y dynamically initialized, so it is not required to be initialized before s.