[Info-vax] [OT?] Should compiler warnings be treated as errors ?

dthi...@gmail.com dthittner at gmail.com
Fri Sep 10 18:05:17 EDT 2021


> > 
> > What do you think ? Should compiler warnings be treated as errors ? 
> > 

I was assigned to a Fortran-and-C based VMS project a few years ago, with 1.5 million LOC. One day, while analyzing the system for better ways to build and repackage the software, I noticed that all the compiles were done with /NOWARN. The original developers had added /NOWARN to their compilation scripts so that they (quote) "didn't have to see all the nasty warning messages". This had been going on, believe it or not, for 30 years!

When we enabled warnings, we generated 56K warnings in the first full compilation run, many of them quite severe, such as COMMON block variable misalignment, and Jump into the middle of a loop (skipping the loop initialization). This explained some of the "erratic" behavior that had been reported over the years, and that we had never successfully reproduced or diagnosed, as the problems were data-dependent, and we were not allowed to look at customer data or debug on the customer systems.

After 6 months spent by the coders doing remedial warning correction, we found that the customers no longer experienced these "erratic" data-dependent behaviors after installing the remediated software releases.

So yes, I would totally agree that warnings should generally be treated as errors. If the compiler makers see fit to warn you that you are probably making a mistake in your code, then you probably are, and should take another look.

Fortunately, many of the DEC/Compaq/HP/VSI compilers can turn individual compiler warnings on and off during the run with compiler directives or command line qualifiers, so that you can mask out the truly innocent warnings.

David




More information about the Info-vax mailing list