digitalmars.D.bugs - [Issue 16234] New: ICE on opEquals
- via Digitalmars-d-bugs (57/57) Jul 03 2016 https://issues.dlang.org/show_bug.cgi?id=16234
https://issues.dlang.org/show_bug.cgi?id=16234 Issue ID: 16234 Summary: ICE on opEquals Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: andrei erdani.com 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 ); --
Jul 03 2016