News for hackers. Stuff that matters.
Re:Everybody makes mistakes when writing comparison functions by jahnu on Thursday September 09, 2021 @07:53AM (#28468658)
As lots of us know from experience, it's very ver hard to get an in-production project into a warning free state with warnings at maximum and warnings as errors. I'm currently working on a new project this year and it has been such a joy to have near max compiler warnings as errors with multiple compilers (and clang tidy and clang format) right from the start.
Re:Everybody makes mistakes when writing comparison functions by AndreyKarpov on Tuesday September 14, 2021 @09:08AM (#28524184)
Integration of a static analyzer into an existing project may be hard. Especially if the project is big and old. In fact, it’s not as scary as it seems to be. There are ways to do it as easy as possible: How to introduce a static code analyzer in a legacy project and not to discourage the team - https://pvs-studio.com/en/blog/posts/0743/
Re:Everybody makes mistakes when writing comparison functions by IanSanders on Thursday September 09, 2021 @08:04AM (#28468736)
Warning definitions also change over time with new versions
Re:Everybody makes mistakes when writing comparison functions by stinos on Thursday September 09, 2021 @09:13AM (#28469273)
it's very ver hard to get an in-production project

True, especially for older projects which never cared about warnings to begin with. Still when I encounter one I might try it anyway, gradually if possible, to see what comes out. Not just because it is indeed just joy to have no warnings, but also because more often than not some of those warnings actually tell you there are bugs. Or for example (just had this last week) because there are projects which compile with 10k+ warnings which mean that even if you just compile a single file, it is way to hard to tell whether your new code just introduced a new warning and if so which one it is.

Re:Everybody makes mistakes when writing comparison functions by jahnu on Thursday September 09, 2021 @10:01AM (#28469779)
Absolutely.

One strategy I employed with a very old code base with a gajillion warnings was to output them to a file and compare against a reference file at the end of the build. If the output changed we would fix those and maybe any that kept happening if you added new compilation units etc. It at least helped us slowly reverse the trend of accumulating warnings.

Re:Everybody makes mistakes when writing comparison functions by lelanthran on Thursday September 09, 2021 @03:05PM (#28473378)
I did the same, but it meant that the build could not go in parallel.

I also stored the warnings.txt in git so that before any commit I could simply do a git diff to see what warnings were changed by my additions.