www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15478] New: Constant folding inconsistency

https://issues.dlang.org/show_bug.cgi?id=15478

          Issue ID: 15478
           Summary: Constant folding inconsistency
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: thomas.bockman gmail.com

struct Foo(N)
{
    this(N value) { }
    auto bug() { return 0; }
}

void main()
{
    enum Foo!int foo = 0;
    Foo!int[foo.bug] bar; // Error: integer constant expression expected
instead of Foo().bug

    enum foo_bug = foo.bug;
    Foo!int[foo_bug] baz; // OK
}

The declarations of `baz` and `bar` should be semantically equivalent, but
apparently something went wrong with `bar`.

(This was reduced from a much larger program which triggered the problem
seemingly at random. very annoying.)

--
Dec 26 2015