3668 – foreach over typedef'd array crashes dmd

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3668 - foreach over typedef'd array crashes dmd
Summary: foreach over typedef'd array crashes dmd
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 regression
Assignee: No Owner
URL:
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
Reported: 2010年01月03日 15:00 UTC by Stephan Dilly
Modified: 2015年06月09日 01:26 UTC (History)
4 users (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 Stephan Dilly 2010年01月03日 15:00:13 UTC
This code used to work up to version 2.031 without problems, since 2.032 it manages to crash dmd.
[CODE]
typedef byte[] Foo;
Foo bar;
foreach(value; bar){}
[/CODE]
Comment 1 Don 2010年01月04日 07:24:58 UTC
There's a missing toBaseType() in the Foreach code which was introduced in D2.032.
PATCH:
statement.c, line 1525, in ForeachStatement::semantic():
------
	 Identifier *id = Lexer::uniqueId("__aggr");
	 ExpInitializer *ie = new ExpInitializer(loc, new SliceExp(loc, aggr, NULL, NULL));
-	 VarDeclaration *tmp = new VarDeclaration(loc, aggr->type->nextOf()->arrayOf(), id, ie);
+	 VarDeclaration *tmp = new VarDeclaration(loc, aggr->type->toBasetype()->nextOf()->arrayOf(), id, ie);
	 Expression *tmp_length = new DotIdExp(loc, new VarExp(loc, tmp), Id::length);
Comment 2 Andrei Alexandrescu 2010年01月04日 08:47:18 UTC
typedef is gone.
Comment 3 Stephan Dilly 2010年01月04日 09:16:23 UTC
huh ? it is gone ? in dmd 2.032 - 2.039 it is certainly not, otherwise the compiler would complain using it (puting this crash aside). since when is typedef gone and why ?
Comment 4 Stephan Dilly 2010年01月04日 09:19:18 UTC
whatever is meant by "typedef is gone" the compiler should not crash under any circumstance. feel free to change the keywords to ice-on-invalid if that is the actual case.
Comment 5 Walter Bright 2010年01月23日 01:41:48 UTC
Changeset 350
Comment 6 Walter Bright 2010年01月30日 22:40:54 UTC
fixed dmd 1.056 and 2.040


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