[Bug c++/34180] Default copy constructor copies const auto_ptr members
likeuclinux at yahoo dot ca
gcc-bugzilla@gcc.gnu.org
Thu Nov 5 21:16:00 GMT 2009
------- Comment #7 from likeuclinux at yahoo dot ca 2009-11-05 21:16 -------
Please, this is definitely bug from GCC, for same code give me error in Visual
Studio 2008 but not in GCC:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <memory>
using namespace std;
class A{
public:
A() : p(new int(10)){
}
const auto_ptr<int> p;
};
int main() {
A a;
printf("a pointer=0x%x\n", a.p.get());
A a2 = a;
printf("a pointer=0x%x\n", a.p.get());
printf("a2 pointer=0x%x\n", a2.p.get());
return 0;
}
Error:
Error 1 error C2558: class 'std::auto_ptr<_Ty>' : no copy constructor
available or copy constructor is declared 'explicit' c:\documents and
settings\charlie\my documents\visual studio 2008\projects\debug\debug\test.cpp
19 debug
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34180
More information about the Gcc-bugs
mailing list