Bug 4828 – ICE w/ non-boolean dot expression sth.template_instance in static if

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-09-05T23:25:00Z
Last change time
2010-09-11T13:22:37Z
Keywords
ice-on-invalid-code, patch
Assigned to
nobody
Creator
rsinfu

Attachments

IDFilenameSummaryContent-TypeSize
748ice-member-tinstance.patchPatch against dmd r660, implements DotExp::toCBuffer()text/plain811

Comments

Comment #0 by rsinfu — 2010-09-05T23:25:53Z
Using an syntax `something.template_instance` in static-if triggers an assertion at expression.c(817). -------------------- struct S { template P() {} alias P!() p; } static if (S.p) {} // ICE -------------------- % dmd -o- -c test Assertion failed: (pr != PREC_zero), function expToCBuffer, file expression.c, line 817. -------------------- Assertion failure did not occur before svn r629. -------------------- % dmd-r628 -o- -c test test.d(6): Error: expression S dotexp P!() is not constant or does not evaluate to a bool --------------------
Comment #1 by rsinfu — 2010-09-05T23:28:59Z
Created attachment 748 Patch against dmd r660, implements DotExp::toCBuffer() The attached patch implements DotExp::toCBuffer(). The syntax `something.template_instance` yields a DotExp. The repro code in comment #0 is invalid, and the compiler tries to generate an error message. Then it calls toCBuffer() on the DotExp object, but it's not overridden, so the base class' BinExp::toCBuffer() is invoked. It hits the assertion because `precedence[TOKdotexp]` is PREC_zero: -------------------- void BinExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { expToCBuffer(buf, hgs, e1, precedence[op]); // op == TOKdotexp ... -------------------- So, DotExp::toCBuffer() needs to be implemented to handle this case.
Comment #2 by clugdbug — 2010-09-06T04:19:52Z
Another regression from the same svn commit, that hits the same assert: static assert(!is(typeof(Object.tupleof[2000]=0))); --- precedence not defined for token 'tuple' assert expression.c(816) precedence[e->op] != PREC_zero
Comment #3 by bugzilla — 2010-09-11T13:22:37Z