Bug 1969 – ICE(cod1.c) using undefined operator with one const operand
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-04-02T09:42:00Z
Last change time
2015-06-09T01:14:37Z
Keywords
ice-on-invalid-code, patch
Assigned to
nobody
Creator
sardonicpresence
Comments
Comment #0 by sardonicpresence — 2008-04-02T09:42:08Z
The following code results in an Internal error in DMD 2.012:
////////
struct Foo { }
struct Bar
{
public Foo opSub(Bar other)
{
return Foo();
}
}
void main()
{
// Removing the following const eliminates the error
const Foo test = Foo();
// Causes the error as (Foo + Foo) is undefined
auto result = test + (Bar() - Bar());
auto ok1 = test + test; // No error
auto ok2 = test + Foo(); // No error
}
////////
Comment #1 by clugdbug — 2009-05-19T01:01:53Z
Simplified test case
struct Bar{ }
const(Bar) baz() { return Bar(); }
void foo() {
Bar result = Bar() + baz();
}
Comment #2 by clugdbug — 2009-07-13T04:53:56Z
/* Root cause: BinExp::typeCombine() is checking for an _exact_ match, but
typeMerge() will return success.
PATCH: cast.c BinExp::typeCombine().
Compare the immutable versions of the types, instead of the types themselves.
if (op == TOKmin || op == TOKadd)
{
if (t1->ito == t2->ito && (t1->ty == Tstruct || t1->ty == Tclass))
goto Lerror;
}
*/