Comment #1 by ellery-newcomer — 2011-01-29T05:33:22Z
(In reply to comment #0)
> The execution of this code throws an assertion error.
>
I can't seem to reproduce this.
dmd 2.051, linux
Comment #2 by dransic — 2011-01-29T06:22:56Z
(In reply to comment #1)
> (In reply to comment #0)
> > The execution of this code throws an assertion error.
> >
>
> I can't seem to reproduce this.
>
> dmd 2.051, linux
Weird. I have this error every time I run the code in
- dmd 2.050 & 2.051 Mac OS X (differents systems)
- dmd 2.051 Linux (Ubuntu 10.10) / Parallels Desktop
I will try on a PC with MSWindows this evening.
Comment #3 by issues.dlang — 2011-01-29T18:03:45Z
I'm not getting this to happen with dmd 2.051 on Arch Linux either (Phobos and druntime are from git). However, if I use the example that you originally gave on D.learn:
import std.array, std.datetime;
unittest {
auto app = appender!(Interval!Date[]);
auto interval = Interval!Date(Date(2000, 1, 1), Date(2011, 2, 3));
app.put(interval);
// Error: datetime.d(20208): Invariant Failure: begin is not before
or equal to end.
}
it happens some of the time but not all of the time. So, whatever the bug is exactly, it's non-deterministic, and it may easily get affected by the OS that you're on. It may be that some slight tweaks would make it pop up on boxes which currently can't reproduce it. I'm convinced that there is a bug here, but it's non-deterministic enough, that depending on the code and the machine, it could either be reproduced easily or only with difficulty.
Comment #4 by issues.dlang — 2011-01-31T17:40:56Z
Actually, I think I know what's happening (roughly speaking). This problem is caused by bug# 5058. Appender has uninitialized data which it then tries to assign to using the assignment operator. Because the invariant is called before opAssign (which I argue in bug# 5058, that it shouldn't be), the invariant is called on garbage data. Sometimes, that garbage data violates the invariant, and sometimes it doesn't. So, unless there's something that Appender can do to work around bug# 5058, it's likely not a bug in Appender so much as it's a bug in how invariants work with regards to opAssign.
Comment #5 by dransic — 2011-01-31T22:50:35Z
> Actually, I think I know what's happening (roughly speaking). This problem is
> caused by bug# 5058.
I think you are right, these bugs look very similar.
It definitely is related to opAssign, since it never occurs when opAssign is not redefined. This would also mean that the compiler-generated opAssign is either not calling invariant() or calling it at the right time, after data is properly initialized. But I don't know what happens behind the scene in this matter.
Comment #6 by beatgammit — 2013-05-23T00:05:43Z
I can't reproduce this:
DMD 2.062
LDC2 (based on 2.061)
Arch Linux x86_64
Can anyone else reproduce this? This bug is quite old...