[SERVER-7273] documenttests.cpp:808 warning about int64->double truncation Created: 05/Oct/12  Updated: 11/Jul/16  Resolved: 11/Oct/12

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: 2.3.0
Fix Version/s: 2.3.0

Type: Bug Priority: Trivial - P5
Reporter: Andy Schwerin Assignee: Aaron Staple
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

The MSVC compiler emits a warning about precision loss when converting int64_t(0x8fffffffffffffffLL) to a double. We'd like our compiles to be warning-free. The correct solution here is probably to suppress the warning on Windows, since we're intentionally trying to lose precision for this test.



 Comments   
Comment by auto [ 11/Oct/12 ]

Author:

{u'date': u'2012-10-10T16:59:13-07:00', u'email': u'aaron@10gen.com', u'name': u'Aaron'}

Message: SERVER-7273 Use static_cast when passing long long to Value::createDouble().
Branch: master
https://github.com/mongodb/mongo/commit/a7c4ae5de9e17fc72f33a34d4e92ccd58c099f62

Comment by auto [ 10/Oct/12 ]

Author:

{u'date': u'2012-10-07T20:49:14-07:00', u'email': u'aaron@10gen.com', u'name': u'Aaron'}

Message: SERVER-7273 Use static_cast in unit test.
Branch: master
https://github.com/mongodb/mongo/commit/0235bac4b8469e26204e869d52a7fbdc51ae35a4

Comment by Aaron Staple [ 10/Oct/12 ]

<http://buildbot.mongodb.org/builders/Windows%2064-bit/builds/5071/steps/compile/logs/stdio>

Comment by Tad Marshall [ 05/Oct/12 ]

I think that static_cast<double>( 0x8fffffffffffffffLL ) would make the warning go away without "suppressing" it. The warning is telling you that you didn't explicitly make this conversion yourself and maybe you weren't expecting to lose precision. If you static_cast it yourself, the compiler knows that this is on purpose.

Generated at Thu Feb 08 03:14:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.