Bug 11919 – GitHub HEAD regression for getAttributes trait (DMD CORE DUMP)
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-13T09:36:00Z
Last change time
2014-01-14T13:17:27Z
Keywords
ice, pull
Assigned to
nobody
Creator
puneet
Comments
Comment #0 by puneet — 2014-01-13T09:36:53Z
Reduced with dustmite -- line 7 of foobar.d does not make sense to me, but compiler does not seem to mind it. In my original (50000 lines) code, I have legal code and am getting same error with dmd HEAD. dmd-2.064 works fine with original code.
When I compile with dmd 2.064, the following reduced code compiles and runs. When compiled with latest Github HEAD, I get a dmd CORE DUMP and before that a compiler error that does not come with dmd-2.064.
$ dmd -c test.d
test.d(4): Error: undefined identifier foo, did you mean variable zoo?
dmd: interpret.c:310: static int CompiledCtfeFunction::walkAllVars(Expression*, void*): Assertion `0' failed.
Aborted (core dumped)
Also when I comment out foobar.d line 7, dmd HEAD gives the same error again with a CORE DUMP. With line 7 commented, dmd-2.064 also behaves in a strange fashion.
$ dmd-2.064 test.d
test.d(4): Error: Cannot interpret foo at compile time
test.d(4): Error: Cannot interpret foo at compile time
// foobar.d
module foobar; // 1
void doBar(T)(T t) { // 2
static if(t.tupleof.length) // 3
if(zoo!t.length == 0){} // 4
static if(is(T B == super) // 5
&& is(B[0] == class) // 6
&& is(B[]) // 7
) { // 8
B[0] b = t; // 9
doBar(b); // 10
} // 11
} // 12
template zoo(alias t) { // 13
enum zoo = __traits(getAttributes, t.tupleof); // 14
} // 15
// test.d
import foobar; // 1
enum foo; // 2
class Foo { // 3
@foo bool _foo; // 4
} // 5
class Bar: Foo {} // 6
void main() { // 7
auto bar = new Bar(); // 8
bar.doBar; // 9
} // 10
Comment #1 by k.hara.pg — 2014-01-13T20:42:37Z
https://github.com/D-Programming-Language/dmd/pull/3090
Note that, even if ICE issue will be fixed, OP code will continue fail to compile. Because is(B[]) at line 7 in foobar.d is changed to return true from 2.065, by fixing issue 8244.
Comment #2 by github-bugzilla — 2014-01-14T13:14:42Z