It’s best to try to remove ALL compiler warnings by any means

Our project manager recently set up a policy to ask developers to remove ALL compiler warnings. I understand that some warnings are really easy to delete, some of them are not so simple. Therefore, some developers use all possible ways to achieve the goal. For example, using explicit listing to float, float to int, unsigned signature, etc. Etc. Since our code base is so large that more than 30 years of work by 30-50 developers, I really doubt that how much this effort can really help us if it has some advantages. Can someone give some of your advice or arguments? Our project uses C ++. Thank.

+5
source share
3 answers

Once you enable compiler warnings, "real" warnings are also ignored. I can’t count the number of times when I came to the project with tons of warnings that were carefully removed with a bunch of very subtle errors. Random assignment in case of accidental failure in the switch or without default, random; at the end of a for loop, unintended casting, etc. Warnings exist for some reason - use them. Yes, some of them are very penitentiary, but only a little work will save a lot of headache later.

Clean warnings and keep them clean. You will write the best code.

+13
source

. , .

: , , .

: , - , undefined, . , , , , , .

- . , , , ( ). , , .

+3

. " , ".

. , - .

" " - , , , ( ), , , [ , , ( )].

, , - , " ", , " " - , ? ( ) - .

, - , "" , , , , .

, , , , , " ".

In most cases, warnings are “good” for the programmer and should not be ignored. But there are times when "I know what I'm doing, shut up to the compiler!" this is the right approach - of course, in most cases, this is fixed by applying a throw or some such - and this should be done when this is the right way to fix the problem.

+3
source

All Articles