3919 – ICE(expression.c, 9944): * or / with typedef ireal

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3919 - ICE(expression.c, 9944): * or / with typedef ireal
Summary: ICE(expression.c, 9944): * or / with typedef ireal
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
Reported: 2010年03月09日 18:01 UTC by Aldo Nunez
Modified: 2014年02月15日 02:43 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 Aldo Nunez 2010年03月09日 18:01:17 UTC
The error is in MulExp::semantic. It happens no matter if the multiplication expression is in a template. These are the combinations that fail:
IF * ifloat
IF * IF
ID * idouble
ID * ID
IR * ireal
IR * IR
Here's a sample:
import std.stdio;
typedef ifloat IF;
typedef idouble ID;
typedef ireal IR;
template PrintAddedType(X, Y)
{
	void PrintAddedType()
	{
		X x;
		Y y;
		writeln( typeid( x ), " ", typeid( y ), " ", typeid( x * y ) );
	}
}
template PrintAddedType(X)
{
	void PrintAddedType()
	{
/*
		PrintAddedType!(X, ifloat)();
		PrintAddedType!(X, idouble)();
		PrintAddedType!(X, ireal)();
*/
/*
		PrintAddedType!(X, IF)();
		PrintAddedType!(X, ID)();
		PrintAddedType!(X, IR)();
*/
	}
}
void main()
{
/*
	PrintAddedType!(IF)();
	PrintAddedType!(ID)();
	PrintAddedType!(IR)();
*/
	IR x;
	IR y;
	writeln( typeid( x ), "\t", typeid( y ), "\t", typeid( x * y ) );
}
Comment 1 Don 2010年03月10日 23:56:01 UTC
Applies to D1 as well.
Reduced test case for test suite, for both this bug and the next one:
-------
typedef ireal BUG3919;
alias typeof(BUG3919.init*BUG3919.init) ICE3919;
alias typeof(BUG3919.init/BUG3919.init) ICE3920;
-------
Simple: It's not obtaining the base type before checking if it is an imaginary type.
PATCH:
Expression.c MulExp::semantic, around line 9935.
Apply exactly the same to DivExp::semantic, around line 10003, to fix bug 3920.
 if (!e1->isArrayOperand())
	e1->checkArithmetic();
 if (!e2->isArrayOperand())
	e2->checkArithmetic();
 if (type->isfloating())
- {	Type *t1 = e1->type;
-	Type *t2 = e2->type;
+ {	Type *t1 = e1->type->toBasetype();
+	Type *t2 = e2->type->toBasetype();
Comment 2 Walter Bright 2010年03月12日 20:52:58 UTC
changeset 415
Comment 3 Don 2010年04月09日 13:40:06 UTC
Fixed DMD1.058 and 2.042.


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