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, Funny) by stretch611 on Monday October 23 2017, @11:57AM (2 children)

    by stretch611 (6199) on Monday October 23 2017, @11:57AM (#586286)

    Anyone have samples of code where you just knew the compiler or static analyzer was wrong, only to find out otherwise? --martyb

    Never, my code is ALWAYS correct... the computer is always at fault.

    Whether it is just to stupid to understand my genius, mistakes the position of the shift key to display the wrong case, has byte degradation in memory to change my periods to commas, or just blatantly lies and thinks I typed functions from a language other than the one I am working on... It is always the computer.

    --
    Now with 5 covid vaccine shots/boosters altering my DNA :P
    Starting Score:    1  point
    Moderation   +1  
       Funny=1, Total=1
    Extra 'Funny' Modifier   0  
    Karma-Bonus Modifier   +1  

    Total Score:   3  
  • (Score: 3, Interesting) by stretch611 on Monday October 23 2017, @11:59AM

    by stretch611 (6199) on Monday October 23 2017, @11:59AM (#586289)

    tbh... I'm the type that worries when something compiles clean the first time. There is always a coding error and I prefer the computer to find a simple syntax error or some other flub, instead of me having to track down the logic error the computer can't see later.

    --
    Now with 5 covid vaccine shots/boosters altering my DNA :P
  • (Score: 2) by bzipitidoo on Monday October 23 2017, @11:26PM

    by bzipitidoo (4388) on Monday October 23 2017, @11:26PM (#586646) Journal

    Compiler error messages are always stupidly obtuse, when they bother to say anything at all! "Bad Lvalue!" WTF? ALGOL is dead, stop using ALGOL concepts in the error messages! And stop thinking there's no room for more comprehensible error messages, this is not the 1960s anymore, when 1K was a lot of memory. Could the compiler at least spell it out, you know, say "left value" instead of "lvalue"? Maybe even "the expression on the left side of the assignment operator"?

    And, leave out one tiny little semicolon or brace, and the compiler goes nuts. Thinks ill of every line after such an insignificant error and spams the programmer with a lot of useless and untrue error messages. It's like the compiler is trying to make the real error message scroll off the top so the programmer can't read it! If a compiler like that was a 1st grader, it would've been diagnosed with autism and ADHD the first time it had such a huge meltdown over a bit of missing punctuation.