[Issue 23268] clamp no longer accepts shorts
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jul 25 11:47:59 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23268
--- Comment #2 from RazvanN <razvan.nitu1305 at gmail.com> ---
Additional information: a reduction of the phobos code that manifests in this
case is:
void main()
{
clamp(short.init, short.init, cast(const)short.init);
}
T1 clamp(T1, T2, T3)(T1 val, T2 lower, T3 upper)
if (is(typeof(val < lower ? lower : val > upper ? upper : val) : T1))
{
return val < lower ? lower : val > upper ? upper : val;
}
The problem is that the resulting type of the ternary expression is int instead
of shared. It wrongfully casts the operands to int, as a result of 16235.
--
More information about the Digitalmars-d-bugs
mailing list