This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
egcs bug report
- To: egcs-bugs at cygnus dot com
- Subject: egcs bug report
- From: Jason Fischl <jfischl at ibm dot net>
- Date: Sun, 14 Dec 1997 15:13:32 -0800
- Organization: Image Integration Inc.
- Reply-To: egcs-bugs at cygnus dot com
[124] ~/src/atcserver >g++ -v
Reading specs from
/usr/local/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.90.21/specs
gcc version egcs-2.90.21 971202 (egcs-1.00 release)
[129] /tmp >uname -a
Linux singha.iii.ca 2.0.32 #3 Sat Dec 13 16:49:52 PST 1997 i586
../src/egcs-1.0/configure --host=i586-pc-linux-gnulibc1 --norecursion
Problem description:
--------------------
The compiler generates a warning under the following conditions. I
define a
class with no public constructors and no friends but I define a static
function which is public which in turn calls the private constructor if
necessary. This works as long as I don't define a "dummy" constructor
and
"dummy" copy constructor (which prevents someone from using the
defaults). When I define these, the compiler outputs a warning,
"warning: `class Test' only defines private constructors and has no
friends"
Examples:
---------
//
// Problem file
// g++ -c t2.cc -o t2.o
// t2.cc:14: warning: `class Test' only defines private constructors and
has no friends
#include <stdio.h>
class Test
{
public:
static Test& instance();
private:
Test();
Test(const Test& other);
Test& operator=(const Test& other);
static Test* test;
};
Test* Test::test=NULL;
Test&
Test::instance()
{
if (test == NULL)
{
test = new Test;
}
return *test;
}
// This one is ok
// g++ -c t2.cc -o t2.o
// no errors or warnings
#include <stdio.h>
class Test
{
public:
static Test& instance();
private:
Test();
static Test* test;
};
Test* Test::test=NULL;
Test&
Test::instance()
{
if (test == NULL)
{
test = new Test;
}
return *test;
}
--
Jason Fischl Tel: (604) 737-8547
Consultant Fax: (604) 737-8776
Image Integration Inc. Email: j.fischl@ieee.org
------------------------------------------------------------