4864 – ICE(statement.c) Crash on invalid 'if statement' body inside mixin

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4864 - ICE(statement.c) Crash on invalid 'if statement' body inside mixin
Summary: ICE(statement.c) Crash on invalid 'if statement' body inside mixin
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-invalid-code, patch
Depends on:
Blocks:
Reported: 2010年09月14日 00:01 UTC by yebblies
Modified: 2010年12月08日 01:02 UTC (History)
2 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 yebblies 2010年09月14日 00:01:51 UTC
----- reduced test case -----
void main()
{
 mixin("if (0) % ;");
}
-----------------------------
IfStatement::semantic is called with (ifbody == null)
Seems like something that should be detected during parsing of the mixin.
Comment 1 yebblies 2010年09月15日 02:13:58 UTC
Additional test case:
void main()
{
	mixin("if (a b) ;");
}
Another case of a broken if statement.
The crash goes away if a body is added to the if statement.
Comment 2 Don 2010年11月17日 00:13:39 UTC
PATCH: statement.c 337.
CompileStatement::flatten()
 Statements *a = new Statements();
 while (p.token.value != TOKeof)
 {
+ int olderrs = global.errors;
 Statement *s = p.parseStatement(PSsemi | PScurlyscope);
+ if (olderrs == global.errors) // discard it if parsing failed
 a->push(s);
 }
Comment 3 Walter Bright 2010年12月04日 22:57:08 UTC
http://www.dsource.org/projects/dmd/changeset/778 
Comment 4 Walter Bright 2010年12月04日 22:57:26 UTC
http://www.dsource.org/projects/dmd/changeset/778 


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