Bug 5182 – ICE(expression.c): calling unittest from a function
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-11-06T13:52:00Z
Last change time
2010-12-04T23:48:43Z
Keywords
accepts-invalid, ice-on-invalid-code, patch
Assigned to
nobody
Creator
ibuclaw
Comments
Comment #0 by ibuclaw — 2010-11-06T13:52:04Z
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 by ibuclaw — 2010-11-06T14:02:30Z
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 by ibuclaw — 2010-11-08T03:14:28Z
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