Here is a code snippet:

class test{

public:
test(){
cout<<"I am in default constructor ";
}
static void func(const test &obj){
cout<<"I am in function ";
}
protected:
test( const test &o){
cout<<"I am in copy constructor ";
}

};

int main() {
test::func(test());
}

The above code gives following error with g++ 3.4.6(on Red Hat Linux) on compilation: In function int main()': error:test::test(const test&)' is protected
error: within this context

However if you compile with g++ 3.3.2 or g++ 4.4.3 (on Red Hat Linux),it compiles successfully and gives following output:

I am in default constructor I am in function

In the above code,i have passed the temporary object(created by default constructor) to function func by reference.So why the compiler 3.4.6 is calling the copy constructor?