public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pmladek at suse dot cz" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/25390] gcc-4.1.0: Invalid warning: control reaches end of non-void function
Date: Tue, 13 Dec 2005 13:09:00 -0000	[thread overview]
Message-ID: <20051213130857.27247.qmail@sourceware.org> (raw)
In-Reply-To: <bug-25390-275@http.gcc.gnu.org/bugzilla/>



------- Comment #1 from pmladek at suse dot cz  2005-12-13 13:08 -------
First, I am sorry for the first empty message. I pressed enter too fast.

Well, I have got an invalid warning: control reaches end of non-void function
with gcc-4.1.0-pre

The reduced testcase looks like:

--- cut ---
namespace store
{
  class OStoreFile
  {
  public:inline OStoreFile (void) {};
      inline ~ OStoreFile (void) {};
  };
}
using namespace store;

int test (int i1, int i2)
{
  OStoreFile rRegFile;

  if (i2)
    {
      switch (i2)
        {
        case 1:
          return 1;
          break;
        case 2:
          return 2;
          break;
        default:
          return 0;
          break;
        }
    }
  else
    {
      if (i2 == 10)
          return 2;
      else
        return 3; 
    }
}
--- cut ---

Here is the output from g++:

hope:/tmp/gcc.bug # g++ -c -Wall test.ii
test.ii: In function &#8216;int test(int, int)&#8217;:
test.ii:37: warning: control reaches end of non-void function

hope:/tmp/gcc.bug # g++ --version
g++ (GCC) 4.1.0 20051129 (prerelease) (SUSE Linux)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The warning should not be printed because a value is returned in each case.
It seems that the variable OStoreFile rRegFile; is important to reproduce the
problem.


-- 


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


  reply	other threads:[~2005-12-13 13:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-13 13:00 [Bug c++/25390] New: " pmladek at suse dot cz
2005-12-13 13:09 ` pmladek at suse dot cz [this message]
2005-12-13 15:02 ` [Bug c++/25390] " pinskia at gcc dot gnu dot org

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=20051213130857.27247.qmail@sourceware.org \
    --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).