Werror, continued |
2006-02-12
|
Davyd, I was trying to point out that Behdad needs to back up his point more when he says "-Werror should not be used under ANY condition."
Obviously I realize there are cases where it should not be the default and that there are compilers that support it. I'm just saying Behdad should outline his reasons instead of stating dogma and hoping we accept it.
FWIW, here's my take:
1) released versions of a module should not have -Werror enabled by default
2) -Werror should not be used if the compiler doesn't support it
3) CVS versions of a module should have -Werror enabled by default if the compiler supports it, so people hit potential problems and report them, allowing the project maintainers to make an informed decision on how to deal with the warning
4) It is helpful to make it easy for these people to override the error flags; for example, something like "make ERROR_CFLAGS="
1) is so that if someone tries to compile your module with a newer compiler (say, a year from now), the module should still build
2) is obvious
3) is a definite help to increase code quality in your project.
4) is a way of being nice to the brave people testing your code from CVS.
The benefits of this have been very obvious to the GStreamer code ever since we started enabling it for cvs builds.
There are people that claim that "warnings are just warnings" and not necessarily a problem. It's definitely true that sometimes you get warnings that aren't a bug. And if you're superhuman and all-knowing, you may be the one rare person that writes completely correct code even though it spews warnings all over. (Haven't found anyone like this yet though :))
However, it's all a matter of maintenance cost. If your program generates twenty warnings when compiling, how do you remember which ones of those were fine to ignore ? How do you see when a new warning crops up, that might actually be a bug ? Worse, how do you keep other people from adding code to your project that contains genuine bugs that your compiler is telling you about, but you fail to notice the message among the flood of messages you already have ? It's just like the psychological equivalent of the broken window theory - once the first window in an area gets broken, the area quickly detoriates if nothing is done to repair it.
People are very quick to blame the compiler for warnings, and ignore them. But in practice, I've found that in at least half the cases the compiler was right. The cases it was wrong about where easy to get rid of by improving on the code style a little.
The compiler and its warning reports are just a tool, with its advantages and flaws. I prefer to use that tool to maximum effect, and am willing to work around problems in it in my code to reap the benefits - because the benefits of fixing actual bugs are very much worth it.
That's why I'd want Behdad to expand on his point of view - I want to know if I missed any case.