digitalmars.D.bugs - [Issue 17633] New: Unary negation has the wrong type
- via Digitalmars-d-bugs (24/24) Jul 10 2017 https://issues.dlang.org/show_bug.cgi?id=17633
https://issues.dlang.org/show_bug.cgi?id=17633 Issue ID: 17633 Summary: Unary negation has the wrong type Product: D Version: D2 Hardware: All URL: http://dlang.org/ OS: All Status: NEW Severity: enhancement Priority: P3 Component: dlang.org Assignee: nobody puremagic.com Reporter: eyal weka.io Unary negating a ubyte has type ubyte. This is a bug because it contradicts the behavior of the same unary operator syntax in C: enum ubyte x = 1; void assert_minus_1(int y) { assert(y == -1); } static assert(is(typeof(-x) == int), "Violating C's type rules"); unittest { assert_minus_1(-x); // -x is 255, it's zero-extended instead of sign-extended! } --
Jul 10 2017