6375 – [CTFE] Segfault when using std.array.appender with an initial array

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6375 - [CTFE] Segfault when using std.array.appender with an initial array
Summary: [CTFE] Segfault when using std.array.appender with an initial array
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Mac OS X
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
Reported: 2011年07月24日 14:41 UTC by kennytm
Modified: 2011年07月26日 15:19 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description kennytm 2011年07月24日 14:41:19 UTC
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.


AltStyle によって変換されたページ (->オリジナル) /