2851 – Segfault(expression.c) using C-style struct initializer with too few arguments

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2851 - Segfault(expression.c) using C-style struct initializer with too few arguments
Summary: Segfault(expression.c) using C-style struct initializer with too few arguments
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 normal
Assignee: Walter Bright
URL:
Keywords: accepts-invalid, ice-on-invalid-code, patch
Depends on:
Blocks:
Reported: 2009年04月18日 01:48 UTC by Don
Modified: 2014年04月18日 09:12 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 Don 2009年04月18日 01:48:16 UTC
The bug is that it doesn't check that the number of members in the initializer is correct. It's silently accepted as long as you don't access an uninitialised member; if you do, the compiler segfaults.
----
struct Test{
 int foo;
}
enum Test test = {};
enum q = test.foo;
Comment 1 Don 2009年05月14日 01:34:55 UTC
Fixed in DMD2.030, NOT FIXED in DMD1.045.
struct Test{
 int foo;
}
const Test test = {};
const q = test.foo;
Comment 2 Walter Bright 2009年05月15日 12:19:00 UTC
Fixed dmd 2.030
Comment 3 Gide Nwawudu 2009年05月15日 16:13:17 UTC
Re-opened because DMD 1.045 segfaults.
Comment 4 Don 2009年08月13日 00:00:52 UTC
Seems like this was just missed in copying from D2 to D1.
Segfaulting in StructLiteralExp::getFieldIndex() in expression.c.
PATCH: 
Just copy int StructLiteralExp::getFieldIndex(Type *type, unsigned offset)
(line 3197) from D2 to D1. (Needs if(elements->dim){ ... } around the for loop).
Comment 5 Walter Bright 2009年10月13日 13:51:30 UTC
Fixed dmd 1.049


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