This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/14213] New: strange behavior with private cp-cstr...


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]