[gnu.g++.bug] possible bug in g++-1.34.2 re bogus private constructors

whm@UUNET.UU.NET ("Bill Mitchell") (04/12/89)

The following program either illustrates a bug in g++.1.34.2 or a bug in my
understanding.

---------------------------------
void printf(char *, ...);

class A {
    A() {
        printf("Creating A\n");
        }
    };

class B {
    A *ap;
    B(A *p, int x) {
        printf("Creating B\n");
        ap = p;
        }
    };

main()
{
    printf("Starting...\n");
    A a;
    B b(&a, 1);
}
-----------------------------------

When compiled, it produces a couple of warnings:

bug1.cc:7: warning: class A only defines private constructors and has no friends
bug1.cc:15: warning: class B only defines private constructors and has no friends

The code produced for main() has no evidence of the constructors for a and b.
Just on general principles, I would expect further messages rising from the
declarations of a and b when there are no constructors to be used, but perhaps
this is a feature. (???)  If the second argument is elided from B::B(), then
"B b(&a)" will draw an error: "bad argument to constructor B".

This is with g++-1.34.2/gcc-1.34 on a Sun-3 running 4.0.1.

p.s.
I think g++/gdb is still the best thing around; keep up the good work!

--------------------------------------------------------------------
Bill Mitchell				whm@sunquest.com
Sunquest Information Systems		sunquest!whm@arizona.edu
Tucson, AZ 				{arizona,uunet}!sunquest!whm
602-885-7700