According to gcc online documentation, -Wall
includes:
-Waddress -Warray-bounds (only with -O2) -Wc++0x-compat -Wchar-subscripts -Wenum-compare (in C/Objc; this is on by default in C++) -Wimplicit-int (C and Objective-C only) -Wimplicit-function-declaration (C and Objective-C only) -Wcomment -Wformat -Wmain (only for C/ObjC and unless -ffreestanding) -Wmissing-braces -Wnonnull -Wparentheses -Wpointer-sign -Wreorder -Wreturn-type -Wsequence-point -Wsign-compare (only in C++) -Wstrict-aliasing -Wstrict-overflow=1 -Wswitch -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunused-function -Wunused-label -Wunused-value -Wunused-variable -Wvolatile-register-var
Of these, -Wreturn-type
seems to do the trick:
Warn when a function is defined with a return type that defaults to int. In addition, it warns of any return statement without a return value in a function whose return type is not invalid (falling from the end of the function body is considered return without a value) , as well as a return statement with an expression in the function whose return type is invalid.
However, if you enable -Wall
, your code will have too many warnings, I would recommend fixing your code!
source share