Bug 3304 – Segfault using 'is' with a pointer enum.
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2009-09-07T07:47:00Z
Last change time
2015-06-09T01:20:51Z
Keywords
ice-on-invalid-code, patch
Assigned to
nobody
Creator
clugdbug
Comments
Comment #0 by clugdbug — 2009-09-07T07:47:24Z
This is the first bug from bug 3293.
Test case:
---
enum bug3303 = cast(void*)0xFEFEFEFE;
static assert(bug3303 is bug3303);
---
Crashes because e->optimize() is returning NULL. Bug has existed in at least 2.022 to 2.032.
Comment #1 by clugdbug — 2009-09-07T08:00:17Z
Root cause: IndentityExp didn't consider the possibility that Equals() can return CANTINTERPRET.
patch: In optimize.c, IdentityExp::optimize, line 838 (DMD2.032)
if ((this->e1->isConst() && this->e2->isConst()) ||
(this->e1->op == TOKnull && this->e2->op == TOKnull))
{
e = Identity(op, type, this->e1, this->e2);
+ if (e == EXP_CANT_INTERPRET)
+ e = this;
}
return e;