This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Strange warnings
- To: kabatek at chemie dot uni-halle dot de
- Subject: Re: Strange warnings
- From: Gabriel Dos_Reis <Gabriel dot Dos_Reis at sophia dot inria dot fr>
- Date: 05 May 1999 14:43:54 +0200
- Cc: egcs at egcs dot cygnus dot com, egcs-bugs at egcs dot cygnus dot com
- Organization: I.N.R.I.A Sophia-Antipolis (France)
- References: <Pine.LNX.3.96.990505100034.8687A-100000@rumcajs.chemie.uni-halle.de>
Ryszard Kabatek <rysio@rumcajs.chemie.uni-halle.de> writes:
| In the sample below the class X should have a standard constructor
| generated by the compiler. But I get the following warnings:
|
| # eg++ x.cc
| x.cc:6: warning: `class X' only defines private constructors and has no
| friends
| x.cc: In function `static class X * X::create()':
| x.cc:5: no matching function for call to `X::X ()'
| x.cc:3: candidates are: X::X(const X &)
EGCS gets it right. The Standard says:
12.1/5
---
A default constructor for a class X is a constructor of class X that
can be called without an argument. If there is no user-defined
constructor for class X, a default constructor is implicitly
declared ...
---
Since you declared X::X(const X&), the default constructor is not
implicitly declared and it is up to you do so and give it a semantic.
| The first warning I get too if I define a private standard constructor.
| But there is a static function, that creates new instances of X,
| class X does not need friend functions or classes.
It is two way :-) : it can be helpful and quite inappropriate.
-- Gaby