Bug 6049 – [CTFE]: Array literals of structs with invariant() are wrong
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-05-23T21:27:00Z
Last change time
2015-06-09T05:11:49Z
Keywords
wrong-code
Assigned to
nobody
Creator
clugdbug
Comments
Comment #0 by clugdbug — 2011-05-23T21:27:29Z
Applies only to the latest DMD in git. Reduced from unittest failure in std.datetime.
---
struct Bug6049 {
int m;
this(int x) { m = x; }
invariant() { }
}
const Bug6049[] foo6049 = [Bug6049(6), Bug6049(17)];
static assert(foo6049[0].m == 6);
---
Comment #1 by issues.dlang — 2011-05-23T21:35:53Z
So, as a temporary fix to make the autotester is passing, commenting out the invariants should fix the problem?
Comment #2 by clugdbug — 2011-05-24T00:41:06Z
(In reply to comment #1)
> So, as a temporary fix to make the autotester is passing, commenting out the
> invariants should fix the problem?
Yes, but I already have a DMD pull request that fixes the problem <g>.
Comment #3 by issues.dlang — 2011-05-24T10:11:43Z
Then I won't worry about it :). Invariants have been a source of trouble with std.datetime though and appear to be an area in the language implementation that still has some warts. IIRC, it caused some issues with purity initially (though we can now have pure invarians fortunately), and bug# 5058 has caused definite issues as well (hence why SysTime's invariant is commented out). Well, as annoying as such bugs are, at least we're running into them so that we can fix them. Thanks for looking into this one.