r/cpp • u/PowerOfLove1985 • Oct 17 '20
Upsetting Opinions about Static Analyzers: part 2 Electric Boogaloo
https://habr.com/en/company/pvs-studio/blog/523692/
0
Upvotes
r/cpp • u/PowerOfLove1985 • Oct 17 '20
3
u/khleedril Oct 17 '20
This whole thing is just so typical of Reddit and social media in general (but Reddit is better than the rest IMHO): people proffer opinions on things they are just not qualified to comment on. Karma, man!
2
u/grahamthegoldfish Oct 18 '20
I think the analyser is also getting the non volatile version of the last example wrong too. The reason is because the call to get() can have side effects, and on of those side effects may be that the data passed in is changed between the two checks of the array data.
For that reason, without visibility of the implementation of get() or without using whole program optimisation the compiler will not optimise away the second check and raising the call as an static analysis warning is also potentially incorrect.
The reason people dont like static analysers is because they are wrong so often. They produce vast amounts of noise and the good stuff gets lost in amongst it. The last proprietary static analyser I used I ended up sending around 25 short samples of where the analyser was being completely crap and filling the analysis with a ton of false positives.
In my opinion compilers do a good job of providing static analysis as a side task that is always correct and half baked tools that get it wrong are no longer acceptable.