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: [email protected]
Reporter: [email protected]
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!
}
--