Stories
Slash Boxes
Comments

SoylentNews is people

posted by martyb on Monday October 23 2017, @06:48AM   Printer-friendly
from the MY-code-is-perfect! dept.

I am really astonished by the capabilities of static code analysis. The tool surprised me the other day as it turned out to be smarter and more attentive than I am. I found I must be careful when working with static analysis tools. Code reported by the analyzer often looks fine and I'm tempted to discard the warning as a false positive and move on. I fell into this trap and failed to spot bugs...Even I, one of the PVS-Studio developers.

So, appreciate and use static code analyzers! They will help save your time and nerve cells.

[Ed note: I debated running this story as there was an element of self-promotion (aka Bin Spam), but the submitter has been with the site for a while and has posted informative comments. Besides, I know there have been far too many times when I've seen a compiler complain about some section of my code and I'm thinking there is nothing wrong with it — and then I, finally, see my mistake. Anyone have samples of code where you just knew the compiler or static analyzer was wrong, only to find out otherwise? --martyb]


Original Submission

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 2, Informative) by Andrey_Karpov on Monday October 23 2017, @09:27AM (3 children)

    by Andrey_Karpov (6589) on Monday October 23 2017, @09:27AM (#586247) Homepage
    Starting Score:    1  point
    Moderation   +1  
       Informative=1, Total=1
    Extra 'Informative' Modifier   0  

    Total Score:   2  
  • (Score: 3, Insightful) by TheRaven on Monday October 23 2017, @11:43AM

    by TheRaven (270) on Monday October 23 2017, @11:43AM (#586280) Journal
    That entire file is full of things designed around the idea that typing is hard and reading code is so easy that it's worth saving a little bit of typing to avoid a little bit of typing. If you type std::printf, it's 4 more keystrokes than sprintf, but everyone reading your code knows that you're calling a standard library function with very well-known behaviour.
    --
    sudo mod me up
  • (Score: 2) by coolgopher on Monday October 23 2017, @12:40PM

    by coolgopher (1157) on Monday October 23 2017, @12:40PM (#586302)

    Omfg just no! Noooooooooooooo!

  • (Score: 2) by forkazoo on Tuesday October 24 2017, @01:05AM

    by forkazoo (2561) on Tuesday October 24 2017, @01:05AM (#586671)

    Can someone help me figure out the correct git command for creating a pull request that will murder the author?