Article View: gnu.gcc.bug
Article #1451GCC 2.1 emits a bogus warning
From: Dave Gillespie
Date: Tue, 22 Dec 1992 14:27
Date: Tue, 22 Dec 1992 14:27
34 lines
1489 bytes
1489 bytes
While porting some code I got the warning,
> warning: class `foo' only defines private constructors and
> has no friends
which gave me a scare until I realized the class *did* have a
static member function which called "new foo" using the private
constructor. In fact, I notice the warning even appears if I
put the function body using "new" right there in the class
definition!
This warning should probably be suppressed when there are
any public static member functions in the class.
A sample file:
--------
class foo {
int x;
foo(int y) { x = y; }
public:
static foo *make(int a) { return new foo(a); }
};
--------
As far as I know, there is no way to get gcc to suppress this
warning, short of using "-w" to suppress all warnings. It
would be nice if there were a way to suppress specific warnings,
e.g., a #pragma or special comment that would suppress all
warnings on the following line, or a command-line option that
would suppress all warning messages whose text contains a given
string.
-- Dave
Technical Details
Message-ID:
<9212230627.AA10985@thymus.synaptics>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!thymus.synaptics.COM!davegShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!thymus.synaptics.COM!daveg From: daveg@thymus.synaptics.COM (Dave Gillespie) Subject: GCC 2.1 emits a bogus warning Message-ID: <9212230627.AA10985@thymus.synaptics> Sender: gnulists@ai.mit.edu Reply-To: daveg@synaptics.com Organization: GNUs Not Usenet Distribution: gnu Date: Tue, 22 Dec 1992 14:27:06 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 35