3026 – Segfault with incomplete static array initializer

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3026 - Segfault with incomplete static array initializer
Summary: Segfault with incomplete static array initializer
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 All
: P2 normal
Assignee: Walter Bright
URL:
Keywords: ice-on-valid-code, patch, rejects-valid
Depends on:
Blocks:
Reported: 2009年05月26日 14:34 UTC by Shin Fujishiro
Modified: 2015年06月09日 01:27 UTC (History)
0 users

See Also:


Attachments
Fix the problem (dmd 2.030) (1.39 KB, patch)
2009年05月26日 14:34 UTC, Shin Fujishiro
Details | Diff
Additional patch: fix segfault on fwdref (623 bytes, patch)
2009年06月04日 10:06 UTC, Shin Fujishiro
Details | Diff
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 Shin Fujishiro 2009年05月26日 14:34:44 UTC
Created attachment 382 [details] 
Fix the problem (dmd 2.030)
DMD dies without any error message compiling this valid code:
--------------------
immutable int[2] array = [ 42 ];
enum e = array[1];
--------------------
The array initializer in this code contains one element. In this case
ArrayInitializer::toExpression() wrongly generates an ArrayLiteralExp
of one element, not two elements (notice the int[2]). Then DMD references
missing second element, and dies. The patch fixes this problem.
And DMD rejects this valid code:
--------------------
immutable int[1] array = [ 0: 42 ];
enum e = array[0];
--------------------
test.d(1): Error: array initializers as expressions are not allowed
test.d(1): Error: array initializers as expressions are not allowed
test.d(1): Error: array initializers as expressions are not allowed
test.d(1): Error: array initializers as expressions are not allowed
--------------------
ArrayInitializer::toExpression() does not implement support for array
index in static array initializers. The patch also implements it.
Comment 1 Shin Fujishiro 2009年06月04日 10:06:13 UTC
Created attachment 390 [details] 
Additional patch: fix segfault on fwdref
ArrayInitializer will cause a segfault when it's forward referenced. Please apply this patch in addition to the first patch.
Comment 2 Walter Bright 2009年07月09日 02:51:01 UTC
Fixed dmd 1.046 and 2.031


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