4691 – Incorrect comparison of double and long

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4691 - Incorrect comparison of double and long
Summary: Incorrect comparison of double and long
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
Reported: 2010年08月20日 12:15 UTC by Walter Bright
Modified: 2015年06月09日 05:11 UTC (History)
2 users (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 2010年08月20日 12:15:45 UTC
import std.c.stdio;
struct UN
{
 double dd;
 long ll;
}
string cmp( UN * pU )
{
 return pU.dd >= pU.ll ? "OK" : "ERRROR";
}
int main()
{
 static UN u = { 10.50, 10 };
 printf( "%.*s\n", cmp( &u ) );
 return 0;
}
Comment 1 bearophile_hugs 2010年08月20日 13:06:56 UTC
Reduced test case:
double d = 1.5;
long l = 1;
void main() {
 assert(d >= l);
}
Comment 2 Walter Bright 2010年08月21日 16:51:55 UTC
http://www.dsource.org/projects/dmd/changeset/622 


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