https://issues.dlang.org/show_bug.cgi?id=18562
Issue ID: 18562 Summary: expression is not evaluated when accessing manifest constant Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: default_357-l...@yahoo.de Consider: struct Struct { enum Enum = 5; } Struct foo() { while (true) { } return Struct(); } void main() { auto value = foo().Enum; assert(false); } The assert trips, despite the fact that foo() should loop indefinitely, because the compiler optimizes away the call to foo entirely. This is highly unintuitive and also responsible for bug #18560 . Is this really intended? --