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) by JoeMerchant on Tuesday October 24 2017, @02:59AM

    by JoeMerchant (3937) on Tuesday October 24 2017, @02:59AM (#586699)

    I guess I got lucky, I tried to do a few simple things in C++ and it became clear within less than a week that the compiler wasn't doing what the book said it should.

    Your school experience sounds typical late 80s - in my Computer Engineering program, we had a Pascal class, then later we had a Compilers class where we were supposed to write a full assembler using C language, but no C language class as a pre-requisite. Further, the project was supposed to be done on a mainframe that was always down, so I did it in Turbo C on IBM PCs in various other labs and at a friend's house, thinking I would port it to the mainframe when it started working - which it never did. The prof tried to give me a ration of (*#% "porting is not a trivial exercise, the assignment was to do it on the mainframe" - to which I responded "did a single student successfully code anything on that mainframe? It was only working for about 4 hours this semester, total."

    We spent the early 90s coding in C on DOS with PharLap 32 bit extender, using the Menuet GUI library - which we eventually purchased the source code to and ported it to compile in the PharLap environment also. Finally around the fall of '96 we started porting the C project into C++, running Borland's API - whatever they called it. Around 2000, someone bought the code and the first thing they did was hire a team to port it to Visual Studio, cost them about a quarter million to do the port - but the investors were happier that way since they could hire Visual Studio programmers more readily.

    --
    🌻🌻 [google.com]
    Starting Score:    1  point
    Karma-Bonus Modifier   +1  

    Total Score:   2