5182 – ICE(expression.c): calling unittest from a function

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5182 - ICE(expression.c): calling unittest from a function
Summary: ICE(expression.c): calling unittest from a function
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: accepts-invalid, ice-on-invalid-code, patch
Depends on:
Blocks:
Reported: 2010年11月06日 13:52 UTC by Iain Buclaw
Modified: 2010年12月04日 23:48 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 Iain Buclaw 2010年11月06日 13:52:04 UTC
Simplest testcase:
unittest{}
void main() {
 __unittest1();
}
I'm honestly not sure if this is supposed to be legal code. But DMD 2.046 accepts and runs it without problems.
Regards
Comment 1 Iain Buclaw 2010年11月06日 14:02:30 UTC
Oops, sorry, told a while lie.
The program compiles + runs when you pass the compiler flag -unittest, but ICEs when you don't.
Regards
Comment 2 Iain Buclaw 2010年11月08日 03:14:28 UTC
Patch to make SEGV an error:
--- dmd.orig/expression.c 2010年11月08日 10:32:15.492440000 +0000
+++ dmd/expression.c 2010年11月08日 10:39:28.404440000 +0000
@@ -2324,6 +2324,11 @@
 if (!f->originalType && f->scope) // semantic not yet run
 f->semantic(f->scope);
+ if (f->isUnitTestDeclaration())
+ {
+ error("cannot call unittest function '%s'", toChars());
+ return new ErrorExp();
+ }
 if (!f->type->deco)
 {
 error("forward reference to %s", toChars());
Regards
Comment 3 Walter Bright 2010年12月04日 23:48:43 UTC
http://www.dsource.org/projects/dmd/changeset/779 


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