Article View: gnu.g++.bug
Article #1169Warning message: control reaches end of non-void function
From: Joe Picone
Date: Sat, 26 Dec 1992 10:42
Date: Sat, 26 Dec 1992 10:42
47 lines
1483 bytes
1483 bytes
This code:
#include <stdlib.h>
class foo {
private:
int x;
public:
foo() {};
int check(int i);
volatile void exit_handler() {exit(-1);}
};
int foo::check(int i) {
if (i > 0)
{exit_handler();}
else
{return 0;}
}
volatile void foo1() {exit(1);}
int foo2 (int argc) {
if (argc > 2)
{foo1();}
else
{return 0;}
}
produces the following warning message when compiled with
"gcc -c -Wall foo.C":
warning: control reaches end of non-void function
Note that this only occurs with the member function version of this
example. The function version, included above, doesn't produce a
warning message.
This is no doubt the result of some compiler magic going on behind the
scenes, but here is my question:
Shouldn't the declaration of the member function as volatile void
prevent such a warning message from occurring?
Volatile is supposed to be used when the function might never return,
so why doesn't the compiler turn off the warning message in this case?
Technical Details
Message-ID:
<PICONE.92Dec26044229@csc000.csc.ti.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!csc000.CSc.ti.COM!piconeShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!csc000.CSc.ti.COM!picone From: picone@csc000.CSc.ti.COM (Joe Picone) Subject: Warning message: control reaches end of non-void function Message-ID: <PICONE.92Dec26044229@csc000.csc.ti.com> Sender: gnulists@ai.mit.edu Organization: Tsukuba Research and Development Center Distribution: gnu Date: Sat, 26 Dec 1992 10:42:35 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 49