Bug 17637 – Integral promotion rules not being followed

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-07-11T21:43:00Z
Last change time
2017-07-22T21:27:37Z
Assigned to
nobody
Creator
bugzilla
See also
https://issues.dlang.org/show_bug.cgi?id=16997, https://issues.dlang.org/show_bug.cgi?id=17633, https://issues.dlang.org/show_bug.cgi?id=5132

Comments

Comment #0 by bugzilla — 2017-07-11T21:43:27Z
Johan Engelen reports: import core.stdc.stdio; void main() { uint total = 0; void add(int x) { total += x; } ubyte popCount() { return 5; } add(popCount()); add(-popCount()); printf("%u\n", total); // different result from C } The trouble is that -popCount() negates the ubyte before promoting to int, instead of after.
Comment #1 by bugzilla — 2017-07-22T09:50:33Z
16997 has a more succint test case. *** This issue has been marked as a duplicate of issue 16997 ***