On 04/05/2012 02:45 PM, Eric Botcazou wrote:
I personally don't buy the "can't remember" argument. When you use GCC, you just have to remember -g, -O, -W and that's pretty much it.


It is not that they can't remember. I am a TA at a moderately basic programming course, and student submit home assignments with horrible errors. These errors, such as free(*str) or *str=malloc(n) are easily be caught by -Wall. I have to remember to advise them to use -Wall and to fix all the warnings, which I sometimes forget to do.

Many of the students don't know of -Wall because they don't read the gcc manual,
either because they are overwhelmed with assignments and exams, or because
they are intimidated by big manuals written in technical English. Either way, many
won't use -Wall unless they are told to.

My conclusion: it would be much better for beginners to have more warnings turned on.

<rant>
As for specific warnings, I hate that the the code (a&&b || c&&d), which did not cause a warning on older gcc version now gives a warning. I would not want it on by default since it forces users to write too many parentheses in ((a&&b)||(c&&d)) which makes the expression less readable. What next? Warn about (a*b+c*d) ? I would hate to write ((a*b)+(c*d)).

Sure, the precedence of: << vs. +; & vs. == ; & vs. && ; is less clear and deserves a warning, but: & vs. | ; && vs. || ; are at least as common as * vs. + that programmers ought to know
them.
</rant>

Michael

Reply via email to