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: 3, Insightful) by JoeMerchant on Monday October 23 2017, @09:36PM (2 children)

    by JoeMerchant (3937) on Monday October 23 2017, @09:36PM (#586595)

    I'm a believer in zero-warning compiles for release code. It doesn't solve every problem, but in my own code I see compiler warnings catching multiple bugs per year that would otherwise be getting by. On the other hand, there are some warnings in some situations that just don't mean anything valuable and can be turned off, in fact are better turned off, so as not to distract from the real warnings that mean something, and also to save the programmers from unreasonable syntactic gymnastics just to shut them up.

    --
    🌻🌻 [google.com]
    Starting Score:    1  point
    Moderation   +1  
       Insightful=1, Total=1
    Extra 'Insightful' Modifier   0  
    Karma-Bonus Modifier   +1  

    Total Score:   3  
  • (Score: 3, Insightful) by The Mighty Buzzard on Monday October 23 2017, @11:05PM (1 child)

    by The Mighty Buzzard (18) Subscriber Badge <themightybuzzard@proton.me> on Monday October 23 2017, @11:05PM (#586631) Homepage Journal

    To each their own. What you call "unreasonable syntactic gymnastics" could just as well be called "doing things properly so you don't make a noobass mistake" though. Like with speech, every time you refuse to listen you eliminate the chance of finding out you're wrong and being able to correct yourself.

    --
    My rights don't end where your fear begins.
    • (Score: 2) by JoeMerchant on Monday October 23 2017, @11:52PM

      by JoeMerchant (3937) on Monday October 23 2017, @11:52PM (#586652)

      I'm o.k. with (void) casting unused variables and similar simple things, but some of the signed/unsigned warnings and other more esoteric type casting stuff can get pretty crazy looking to "do it right" when the simple, warned, code is very straightforward to read and understand.

      --
      🌻🌻 [google.com]