Bug 3692 – ICE(mtype.c) with associative arrays when std.variant is imported
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2010-01-08T12:35:00Z
Last change time
2015-06-09T01:27:37Z
Keywords
ice-on-valid-code, patch
Assigned to
nobody
Creator
lmb
Comments
Comment #0 by lmb — 2010-01-08T12:35:25Z
First, I am using DMD 2.039, for which there is no entry on the "Version" field. Anyway, I firstly bumped into this when using DMD 2.037.
So, when compiling this code:
import std.variant;
void main()
{
bool[int] a;
auto x = a.keys[0];
}
The compiler crashes saying:
deferring sigaction_t
dmd: mtype.c:3882: StructDeclaration* TypeAArray::getImpl(): Assertion `impl' failed.
---
Removing the 'import std.variant;' statement solves the problem.
Replacing the 'bool[int]' with 'int[int]' (and still importing std.variant) makes the compiler say:
deferring sigaction_t
But it still generates the executable, which seems to work as expected (that is, throwing a "Range Violation").
Comment #1 by clugdbug — 2010-01-08T22:01:28Z
*** This issue has been marked as a duplicate of issue 3552 ***
Comment #2 by lmb — 2010-02-05T04:18:36Z
This bug has been marked as duplicate of issue 3552, so it should supposedly be fixed in DMD 2.040. Unfortunately, it was not. Using DMD 2.040 to compile the same code as before:
import std.variant;
void main()
{
bool[int] a;
auto x = a.keys[0];
}
I get the same compiler crash as before:
dmd: mtype.c:3886: StructDeclaration* TypeAArray::getImpl(): Assertion `impl' failed.
So, unless I'm doing something very wrong here, I suppose this bug still persists.
Comment #3 by lmb — 2010-02-05T04:42:50Z
Just one additional detail:
In the program where I noticed this problem for the first time, as suggested by others, I worked around the bug by using a copy of std.variant.d with all the occurrences of "AssociativeArray" replaced with something else.
I tried going back to std.variant in my program, and the crash was still there. In other words, it seems that the bug still has something to do with identifiers named "AssociativeArray".
(That said, this code:
void main()
{
int AssociativeArray;
int[int] foo;
foreach (x; foo) { }
}
which I took from issue 3552, compiles cleanly here, which seems to indicate that I am *really* running DMD 2.040 here ;-))
Comment #4 by clugdbug — 2010-02-05T06:23:12Z
(In reply to comment #3)
> Just one additional detail:
>
> In the program where I noticed this problem for the first time, as suggested by
> others, I worked around the bug by using a copy of std.variant.d with all the
> occurrences of "AssociativeArray" replaced with something else.
>
> I tried going back to std.variant in my program, and the crash was still there.
> In other words, it seems that the bug still has something to do with
> identifiers named "AssociativeArray".
Yes. Reduced test case:
---------
import file2;
void main() {
bool[int] a;
auto x = a.keys[0];
}
-------
file2:
--------
int AssociativeArray;
------------------------------
Basically my patch fixed the specific case of bug 3552 but failed in the general case.
Comment #5 by clugdbug — 2010-02-05T06:40:24Z
PATCH: mtype.c line 3870
- // Create .AssociativeArray!(index, next)
+ // Create object.AssociativeArray!(index, next)
DotTemplateInstanceExp *dti = new DotTemplateInstanceExp(loc,
- new IdentifierExp(loc, Id::empty),
+ new IdentifierExp(loc, Id::object),
Id::AssociativeArray,
tiargs);
Or possibly it should be .object.AssociativeArray