[Issue 18562] New: expression is not evaluated when accessing manifest constant
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Mar 6 12:31:47 UTC 2018
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: nobody at puremagic.com
Reporter: default_357-line at 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?
--
More information about the Digitalmars-d-bugs
mailing list