Compiler warnings

KernelTrap has an interesting quote of Linus Torvalds about compiler warnings:

"Please, we do NOT fix compiler warnings without understanding the code! That's a sure way to just introduce _new_ bugs, rather than fix old ones. So please, please, please, realize that the compiler is _stupid_, and fixing warnings without understanding the code is bad.

"In this case, anybody who actually spends 5 seconds looking at the code should have realized that the warning is just another way of saying that the author of the code was on some bad drugs, and the warnings WERE BETTER OFF REMAINING! Because that code _should_ have warnings. Big fat warnings about incompetence!?"


I find it interesting because I have seen bad things happen when people ignore compiler errors. One of the first things I have learn about C programming was to activate all compiler errors. Unfortunately understood this has a chance to avoid bug but as a annoying messages that must be avoided and started working around the messages making their code complex, difficult to read and wrong - I have done this too sometimes... shame on me. Some, even worse, tried "resolving" these warning messages by turning off gcc flags!! This, most of the times, results in strange errors difficult to find and correct in the future which can be exploitable bugs.

So if your code generates compiler warnings, the best thing to do first is to understand why the warning happens and correct the possible problem with it. If you are sure your code is right the the warning is just the compiler being silly - compilers have bugs to - you should not alter the code to remove the warning message. It's a problem with the compiler. Not your code.

Maybe you think you'r sure and blame it on the compiler. Don't remove the warning anyway. Probably you, or someone else, will understand the problem later and correct it. If you turn off the warning, you'll probably have a hard time tracking it down again later.

Comments

  1. This comment has been removed by a blog administrator.

    ReplyDelete

Post a Comment

Popular posts from this blog

Missing Win32_Product

PowerShell: very simple FTP client

Samsung CLP-300