Bug 16234 – ICE on opEquals

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-07-04T03:12:00Z
Last change time
2017-01-18T17:58:32Z
Keywords
ice-on-valid-code
Assigned to
nobody
Creator
andrei

Comments

Comment #0 by andrei — 2016-07-04T03:12:06Z
This code segfaults when built with -unittest: import std.traits : isFloatingPoint, isIntegral, isNumeric, isUnsigned, Unqual; struct Checked(T, Hook) { private T payload; alias hook = Hook; this(U)(U rhs) if (valueConvertible!(U, T)) { payload = rhs; } this(U, Hook1)(Checked!(U, Hook1) rhs) if ((isIntegral!T && valueConvertible!(U, T)) || (!isIntegral!T && is(typeof(T(rhs.payload))))) { payload = rhs.payload; } bool opEquals(U)(U rhs) if (isIntegral!U || isFloatingPoint!U || is(U == bool)) { return payload == rhs; } bool opEquals(U, Hook1)(Checked!(U, Hook1) rhs) if (is(typeof(this == rhs.payload))) { alias R = typeof(payload + rhs.payload); static if (valueConvertible!(T, R) && valueConvertible!(U, R)) { } return payload == rhs.payload; } } struct ProperCompare {} struct WithNaN {} unittest { alias Smart(T) = Checked!(Checked!(T, ProperCompare), WithNaN); Smart!int x1; } private enum valueConvertible(T1, T2) = isIntegral!T1 && isIntegral!T2 && is(T1 : T2) && ( isUnsigned!T1 == isUnsigned!T2 || // same signedness !isUnsigned!T2 && T2.sizeof > T1.sizeof // safely convertible );