Example input: ---------- t.c --------- int something(); int f(int arg) { return 0; (void)(false ? 1 : something()); } ----------------------- $ c++ -c t.cc -finstrument-functions -Wall -Werror t.cc: In function ‘int f(int)’: t.cc:6:1: error: control reaches end of non-void function [-Werror=return-type] } ^ $ echo $? 1 $ But: $ c++ -c t.cc -Wall -Werror $ echo $? 0 $
There is another bug about a similar thing but with constructors/deconstructors. -finstrument-functions inserts try/finally blocks in the code and the dead code is not removed before hand so the warning mechanism gets confused.
Related to bug 20681.
Confirmed. Happens with optimization levels -O0 and -Os, but not -O1, -O2, -O3, -Og, or -Ofast.
Kinda more important now that -Wreturn-type is on by default
(In reply to Eric Gallager from comment #4) > Kinda more important now that -Wreturn-type is on by default ...thus, cc-ing Martin Liska