17637 – Integral promotion rules not being followed

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 17637 - Integral promotion rules not being followed
Summary: Integral promotion rules not being followed
Status: RESOLVED DUPLICATE of issue 16997
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
Reported: 2017年07月11日 21:43 UTC by Walter Bright
Modified: 2017年07月22日 21:27 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Walter Bright 2017年07月11日 21:43:27 UTC
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 Walter Bright 2017年07月22日 09:50:33 UTC
16997 has a more succint test case.
*** This issue has been marked as a duplicate of issue 16997 ***


AltStyle によって変換されたページ (->オリジナル) /