Bug 6390 – [CTFE] Struct constructor fails to call another method

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2011-07-27T08:14:00Z
Last change time
2011-07-28T00:04:05Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bugzilla

Comments

Comment #0 by bugzilla — 2011-07-27T08:14:52Z
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 by clugdbug — 2011-07-28T00:04:05Z
Already fixed in git master. *** This issue has been marked as a duplicate of issue 6337 ***