www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18562] New: expression is not evaluated when accessing


          Issue ID: 18562
           Summary: expression is not evaluated when accessing manifest
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de


struct Struct
    enum Enum = 5;

Struct foo()
    while (true) { }
    return Struct();

void main()
    auto value = foo().Enum;

The assert trips, despite the fact that foo() should loop indefinitely, because
the compiler optimizes away the call to foo entirely. This is highly

Is this really intended?

Mar 06 2018