Bug 6375 – [CTFE] Segfault when using std.array.appender with an initial array
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Mac OS X
Creation time
2011-07-24T14:41:00Z
Last change time
2011-07-26T15:19:16Z
Keywords
ice-on-valid-code
Assigned to
nobody
Creator
kennytm
Comments
Comment #0 by kennytm — 2011-07-24T14:41:19Z
Test case:
-----------------------------
struct D6375 {
int[] arr;
}
A6375 a6375(int[] array) {
return A6375(array);
}
struct A6375 {
D6375* _data;
this(int[] arr) {
_data = new D6375;
_data.arr = arr;
}
int[] data() {
return _data.arr;
}
}
static assert({
int[] a = [ 1, 2 ];
auto app2 = a6375(a);
auto data = app2.data();
return true;
}());
-----------------------------
Bus error: 10
-----------------------------
This is essentially the trimmed down version of the unit test for std.array.appender, running in CTFE. The segfault is due to StructLiteralExp::getField in expression.c:
if (e->type->castMod(0) != type->castMod(0) && type->ty == Tsarray)
// ^^^^ e->type is NULL
Running e->semantic() once fixed the issue, but I'm not sure if this is the best solution.