Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7685171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:11:33+00:00 2026-05-31T19:11:33+00:00

I am getting a coverity static checker tool warning for a piece of code

  • 0

I am getting a coverity static checker tool warning for a piece of code below.

   double value = 0;
   std::string origValue("0.50");
   value = 0.10 * boost::lexical_cast<double>(origValue);

The warning is “Overflowed return value(INTEGER_OVERFLOW)”. I am not able to understand what’s wrong with the code above. And how integer overflow come in to play when I am using doubles? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:11:34+00:00Added an answer on May 31, 2026 at 7:11 pm

    This particular Coverity static analysis checker is looking for two things: the operation which may overflow on particular values (examples of which it will try to give in the explanation) and an unsafe use of the potentially truncated value.

    The UI shows you “events” which explain why something was flagged. The manual describes what each event means. The two events you’re looking for in your case are “truncation” or “overflow” for first event, and “overflow sink” for second event.

    The code snippet shows that a string converted to a double is multiplied by a constant and then assigned to another double. Maybe there is no problem there, however, “Overflowed return value” title of the defect tells us that you have a second event where you return this value from this function. If you are returning “value” from this function and the return type is not double (is it maybe a 32-bit type) then you have a potential bug in your code (clearly not with specific values you are showing, but if string can be a much larger value). If the function is returning double then it is a false positive in the analysis and you can mark it as such in the UI so that the defect won’t be shown to you again.

    Without seeing more of the code, it’s difficult to say if there is a real issue or not, but remember that static analysis can’t know what runtime values are (is the string really constant or is it read in dynamically?) but this is why it gives you detailed events, and not just a one line summary – so you can evaluate the likelihood of a real problem arising in this code.

    Having said all that, the checker is not supposed to track floats so there is definitely a bug in Coverity here. Since I happen to work for them, I’ve filed this as an issue, but feel free to report it to Coverity support as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

getting this error: C:\CodeBlocks\kool\praks3\vector.h|62|error: passing 'const Vector<2u>' as 'this' argument of 'std::string Vector::toString() [with
Getting the above error in following code. How to rectify it. Thanks. Please look
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
Getting warning message that Duplicate protocol definition of ModalViewDelegate is ignored Defined protocol in
Getting this error when I put use Blog; at the top. Warning: The use
Getting the following error: "Warning: Cannot modify header information - headers already sent by
getting below error on IE8 canvas.getContext(2d) Unexpected call to method or property access.Error i
Getting an error with my code found HERE ... Which is a culmination of
Getting a crash when trying to pass the string into NSDateFormatter dateFromString method. I
Getting data from a database table to an object in code has always seemed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.