Summary: [CTFE] Struct constructor fails to call another method
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Lars T. Kyllingstad <> 2011-07-27 
08:14:52 PDT ---
Test case:

    struct Foo
        int i;

        void fun() { --i; }

        this(int a)
            i = a;

    void main()
        assert (Foo(2).i == 1);

    static assert (Foo(2).i == 1);

The above refuses to compile, giving the following error:

    test.d(19): Error: static assert  (2 == 1) is false

This is purely a CTFE issue; if the static assert is removed, the assert in
main() passes at run time, as it should.  It seems the call to fun() is
neglected when the struct is constructed at compile time.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to