gcc-3.4.2/4.0.0 Linux **** 2.6.9 #17 Fri Nov 12 15:59:30 NOVT 2004 i686 athlon i386 GNU/Linux Fedora Core 3 gcc -v Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.2/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disa Thread model: posix gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) g++ test.cpp [megath@hell temp]$ g++ test.cpp test.cpp: In function `int main()': test.cpp:10: error: `A::A(const A&)' is private test.cpp:16: error: within this context test.cpp: class A { public: A() {} const A& operator=(const A& a) { return *this; } private: A(const A& a) {} }; A a; int main() { A *pa = &a; *pa = A(); }
Created attachment 7527 [details] testcase
Invalid, did you read the release notes?
about <i>Copy constructor access check while initializing a reference.</i> ? yes. sorry. *p = A() constructs copy of object now? what for ? doesnt it degrades perfomance?
(In reply to comment #3) > about > <i>Copy constructor access check while initializing a reference.</i> > ? yes. sorry. > *p = A() constructs copy of object now? what for ? No we don't contruct a copy of the object, did you really read it. I just says it has to be accessable, it will not be used. > doesnt it degrades perfomance? Only slightly compile time and that is it.
> I just says it has to be accessable so, if gcc dont use copy ctor - what for it complains ?! and why is it error btw ?
(In reply to comment #5) > > I just says it has to be accessable > so, if gcc dont use copy ctor - what for it complains ?! Because this is the requirement of the C++ standard. > and why is it error btw ? because we could use the ctor if we wantted to in this case but we don't so the requirement of the C++ standard says it has to be accessable.
thank you.