This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14213] New: strange behavior with private cp-cstr...
- From: "pluto at ds14 dot agh dot edu dot pl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Feb 2004 17:03:48 -0000
- Subject: [Bug c++/14213] New: strange behavior with private cp-cstr...
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
class A {
public:
????A()??{?cout?<<?"A::A()\n";??}
????A?&operator?=?(const?A?&obj)
????{
????????cout?<<?"A::operator?=?(const?A?&)\n";
????????return?*this;
????}
//private:
public:
????A(const?A?&obj)?{?cout?<<?"A::A(const?A?&)\n";?}
};
int main()
{
????A?a1;
????A?a2;
????a2?=?a1;
}
# g++ x.cpp -s -o x && ./x
A::A()
A::A()
A::operator = (const A &)
ok.
int main()
{
????A?a1;
????A?a2?=?a1;
}
# g++ x.cpp -s -o x && ./x
A::A()
A::A(const A &)
nice, but if i declare cp-cstr as private...
# g++ x.cpp -s -o x && ./x
x.cpp: In function `int main()':
x.cpp:17: error: `A::A(const A&)' is private
x.cpp:25: error: within this context
why g++ doesn't generate:
A a2();
a2.operator = (a1);
?
--
Summary: strange behavior with private cp-cstr...
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pluto at ds14 dot agh dot edu dot pl
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pld-linux
GCC host triplet: i686-pld-linux
GCC target triplet: i686-pld-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14213