D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6390 - [CTFE] Struct constructor fails to call another method
Summary: [CTFE] Struct constructor fails to call another method
Status: RESOLVED DUPLICATE of issue 6337
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-07-27 08:14 UTC by Lars T. Kyllingstad
Modified: 2011-07-28 00:04 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Lars T. Kyllingstad 2011-07-27 08:14:52 UTC
Test case:

    struct Foo
    {
        int i;

        void fun() { --i; }

        this(int a)
        {
            i = a;
            fun();
        }
    }

    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.
Comment 1 Don 2011-07-28 00:04:05 UTC
Already fixed in git master.

*** This issue has been marked as a duplicate of issue 6337 ***