public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/55767] flowing off end of function which returns a value isn't treated as an error by default
Date: Thu, 20 Dec 2012 19:35:00 -0000	[thread overview]
Message-ID: <bug-55767-4-aIUSmON7CE@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-55767-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55767

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-12-20 19:34:55 UTC ---
It's not always possible to make it a hard error and refuse to compile the
code. The function might call a function that never returns (but isn't marked
with a noreturn attribute) or might be of the form:

  int& f(bool b) {
    if (b) {
      static int i;
      return i;
    }
  }

If this is never called with a false argument there's no problem. If it's never
called at all there's no problem.

Unless GCC's flow analysis is improved I think the most you can hope for is
enabling -Wreturn-type by default.

I use -Werror=return-type, the warning's there already, use it if you want it.


      reply	other threads:[~2012-12-20 19:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-20 19:16 [Bug c++/55767] New: " rui.maciel at gmail dot com
2012-12-20 19:35 ` redi at gcc dot gnu.org [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-55767-4-aIUSmON7CE@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).