[Issue 16997] Real-life evidence for integer promotion of unary minus creating bugs when porting C code

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Dec 20 21:02:24 PST 2016


https://issues.dlang.org/show_bug.cgi?id=16997

--- Comment #3 from Ketmar Dark <ketmar at ketmar.no-ip.org> ---
as for the question: promotion rules are what they are currently to allow this:

byte n;
n = -n;

if unary minus will promote `n`, you will need to add `cast` there. and negate
never ever drop bits from integer (even byte.min is essentially unchanged, so
no info is lost), so it is -- relatively -- safe to not promote here.

--


More information about the Digitalmars-d-bugs mailing list