This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/60725] [-Wreturn-type] false positive in trivial switch
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 04 Sep 2015 18:38:03 +0000
- Subject: [Bug middle-end/60725] [-Wreturn-type] false positive in trivial switch
- Auto-submitted: auto-generated
- References: <bug-60725-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60725
--- Comment #6 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #5)
> Not to complicate things too much, but reaching the closing } of a non-void
> function is valid in C. What is not valid (i.e., has undefined behavior) is
> calling such a function and using its return value when none was provided
> (as in the program in comment #3). The program in the Description, however,
> has well-defined behavior because f1's return value isn't used.
Good point. I don't know whether it is possible for the sanitizers to
distinguish between the two cases.
Pretty sure it is not possible for the warning code, since at the time of
warning we know nothing of the callers (not even if there are any callers).