Adding new gcc warnings

Julien ÉLIE julien at trigofacile.com
Mon May 20 19:33:49 UTC 2013


Hi Russ,

> Based on this discussion, I read through the other options, and am now
> trying:
>
> # A set of flags for warnings.  Add -O because gcc won't find some warnings
> # without optimization turned on.  Desirable warnings that can't be turned
> # on due to other problems:
> #
> #     -Wconversion	http://bugs.debian.org/488884 (htons warnings)
> #
> # Last checked against gcc 4.7.2 (2013-04-22).  -D_FORTIFY_SOURCE=2 enables
> # warn_unused_result attribute markings on glibc functions on Linux, which
> # catches a few more issues.
> WARNINGS = -g -O -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wendif-labels	   \
> 	-Wformat=2 -Winit-self -Wswitch-enum -Wuninitialized -Wfloat-equal \
> 	-Wdeclaration-after-statement -Wshadow -Wpointer-arith		   \
> 	-Wbad-function-cast -Wcast-align -Wwrite-strings		   \
> 	-Wjump-misses-init -Wlogical-op -Wstrict-prototypes		   \
> 	-Wold-style-definition -Wmissing-prototypes -Wnormalized=nfc	   \
> 	-Wpacked -Wredundant-decls -Wnested-externs -Winline -Wvla -Werror

Just a few remarks:

-Werror can be placed before -Wall because it appears before -Wall in 
the GCC manual.

-Wendif-labels is not necessary because it is the default behaviour.

-Wuninitialized is not necessary because it is implied by -Wall.

-Wdeclaration-after-statement can sometimes be useful for clarity (for 
instance declaring a variable only in the loop it is used).  I do not 
know whether this warning should really be enforced.

-Wlogical-op led to unclear code when fixed (according to the other mail 
you wrote about INN; unless I misunderstood your meaning?)

-Wredundant-decls is not used in INN because of noise generated by 
system headers.

-Wmissing-declarations and -Wsync-nand could be added.

Couldn't also the combination "-Wconversion -Wno-sign-conversion" be added?

Couldn't -Wstack-protector along with -fstack-protector be useful?

-- 
Julien ÉLIE

« – C'est joli cette avenue le long de la mer… Ça s'appelle
     comment ?
   – La promenade des Bretons. » (Astérix)


More information about the inn-workers mailing list