[Geany-Devel] Memory leaks in Geany
lists.ban at xxxxx
Wed Sep 25 20:03:56 UTC 2013
Le 25/09/2013 21:48, Pavel Roschin a écrit :
>> Yes, kinda advertized in HACKING -- but -Werror is harder to use
>> because you need to check your flags VERY carefully not to produce
>> any false positive. E.g. -Wwrite-strings have a few false positive
>> due to imperfect API. But yeah, it's nice to stop on possible
>> errors. FTR, we (devs) all (I believe) use this or stricter options
>> (but maybe not with -Werror).
> I think it's better to check compiler warning in 2 minutes than
> spending two days on debugging:) I prefer always enable all warnings in
> new projects. Clearly that Geany is big project and enabling all
> warnings may be quite painful. But it will certainly reduce number of
> errors - when you consider every line of code twice.
AFAIK, we don't currently have any warning reported by GCC that we
didn't consider and just let because it was too boring to fix for no
gain -- what comes to mind is tons of integer size issue, which are not
great but I checked tons of them and they were pretty harmless (yet not
perfectly right otherwise they'd have an explicit cast by now). Also,
compiler warnings are great, but they generally don't suffice to
discover subtle bugs -- and most generally not leaks.
FTR, my well know (;) CFLAGS line is:
-Wall -W -O2 -Wunused -Wunreachable-code -Wformat=2 -Wundef -Wshadow
-Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wconversion
-Waggregate-return -Wstrict-prototypes -Wmissing-prototypes
-Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute
-Wredundant-decls -Wnested-externs -pedantic
I add -g for things I care debugging, and -Wno-unused-parameter to Geany
because, huh, callbacks. I probably should strip these down to
something less pedantic (;) for Geany because they cause too much
warnings, but it's a good start :)
> -Werror is a good practice for people who ignore compiler warnings:)
Yes, but it requires the compiler to generate absolutely no false
positive. And this may require sacrificing an interesting warning flag.
IMHO, developer should rather come up with something that generates a
reasonably small amount of false positive and care about the warnings
than use -Werror and remove a warning that creates one false positive
and breaks their compilation.
> Some stupid warnings may be easily disabled (-Wno-unused-parameter).
Yes, but some clever ones (-Wwrite-strings) may be wanted but generate
warnings on some crazy APIs (like GtkTargetEntry).
More information about the Devel