[gnu.g++.bug] Bug in reference handling?

chatty%FRLRI61.BITNET@CUNYVM.CUNY.EDU (08/30/89)

In the following code, the function foo is called each time the reference x is u

I use g++ 1.35.1- on a Sun3 OS3.5.

class A {
public :
        void bar () {}
};

A&
foo ()
{
        printf ("foo\n");
        return *(new A);
}

main ()
{
        A& x = foo ();
        x.bar ();
        x.bar ();
}

% g++ a.cc
In function struct A &foo ():
a.cc:9: warning: implicit declaration of function `printf'

% a.out
foo
foo
foo


Stephane Chatty         chatty@frlri61.bitnet
                        chatty@lri.lri.fr