Comment #0 by default_357-line — 2018-01-26T16:03:07Z
Steps to reproduce:
void main() { mixin({ return (SysTime.init is SysTime.init) ? "" : ""; }()); }
Expected:
nothing happens
Outcome:
Compiler crashes.
Observation:
I added some logging, and
test.d(5) BinExp::interpretCompareCommon() SysTime(0L, Rebindable(null, )) is SysTime(0L, Rebindable(null, ))
ctfeIdentity op = 'TOKidentity', e1 = SysTime(0L, Rebindable(null, void)), e2 = SysTime(0L, Rebindable(null, void))
test.d(5): Error: CTFE internal error: bad compare of void and void
core.exception.AssertError@ddmd/ctfeexpr.d(1345): Assertion failure
It looks like the second field in RebindableCommon's union ends up void-initialized, and CTFE can't figure out how to compare that.
Comment #1 by default_357-line — 2018-01-26T16:07:49Z
Shorter example:
union S {
int a, b;
}
void main() {
// compiles
if (S.init is S.init) { }
// doesn't compile
mixin({ if (S.init is S.init) return ""; else return ""; }());
}
Comment #2 by default_357-line — 2021-09-13T08:13:18Z