When building DMDFE with warnings enabled (-W -Wall -Wcast-qual), there are literally thousands of messages emitted (most notably seen when building GDC).
Putting default statements at the end of switches cuts the amount down by at least 3 quarters.
See patch against the 1.066 release.
Regards
Comment #1 by ibuclaw — 2011-01-26T09:04:49Z
Created attachment 883
fix most notorious warnings in dmdfe
Comment #2 by ibuclaw — 2011-02-10T15:01:12Z
Created attachment 902
ambiguous 'else' patch
Patch for D2FE: suggest explicit braces to avoid ambiguous 'else'
Comment #3 by ibuclaw — 2011-02-10T15:03:39Z
Created attachment 903
always false patch
Patch for D2FE: comparison of unsigned expression < 0 is always false
Comment #4 by ibuclaw — 2011-02-10T15:06:37Z
Created attachment 904
defined not used patch
Patch for D2FE: ‘zero’ defined but not used
Comment #5 by bearophile_hugs — 2011-02-10T15:08:33Z
Wonderful! See bugs 4375 and bug 5539
Comment #6 by ibuclaw — 2011-02-10T15:19:39Z
Created attachment 905
unused parm header patch
Patch for D2FE: 'unused parameter' emitted from headers.
Comment #7 by ibuclaw — 2011-02-10T15:24:21Z
Created attachment 906
unhandled enum patch
Patch for D2FE: enumeration value not handled in switch
(Last in small batch, and largest of the lot).
Regards, and G'night.
Comment #8 by ibuclaw — 2011-02-10T15:30:21Z
(In reply to comment #5)
> Wonderful! See bugs 4375 and bug 5539
These just address warnings emitted from GCC when building DMD with '-Wall -Wextra', and don't address actually putting these warnings into DMD itself.
To be honest, I'm just tired of seeing thousands of warnings scroll by, makes life very difficult if an actual compiler error occurs. 8-)
Comment #9 by bearophile_hugs — 2011-02-10T15:36:39Z
(In reply to comment #8)
> These just address warnings emitted from GCC when building DMD with '-Wall
> -Wextra', and don't address actually putting these warnings into DMD itself.
I know. Note bug 5539 doesn't ask for a warning, but for an error, so it asks for a change in D2 language itself.
Comment #10 by bugzilla — 2011-02-11T00:52:59Z
I should note that none of these are actual bugs.
Comment #11 by bearophile_hugs — 2011-02-11T03:05:12Z
(In reply to comment #10)
> I should note that none of these are actual bugs.
There is an interesting paper about the topic, "Using Redundancies to Find Errors" by Yichen Xie and Dawson Engle:
http://www.stanford.edu/~engler/p401-xie.pdf
The Abstract:
"This paper explores the idea that redundant operations, like type errors, commonly fag correctness errors. We experimentally test this idea by writing and applying four redundancy checkers to the Linux operating system, finding many errors. We then use these errors to demonstrate that redundancies, even when harmless, strongly correlate with the presence of traditional hard errors (e.g., null pointer dereferences, unreleased locks). Finally we show that how flagging redundant operations gives a way to make specifications fail stop by detecting dangerous omissions."
This for example applies to things like unsigned<0.
Comment #12 by ibuclaw — 2011-05-06T16:10:49Z
GCC-4.6 offers two new warning switches to catch redundant code: -Wunused-but-set-parameter and -Wunused-but-set-variable