"Lev Assinovsky" <LAssinovsky@xxxxxxxxxxxxxxxxxxxx> writes: > Hi all! > With auto_ptr from gcc 3.4 STL I can't create reference to auto_ptr. > > autoptr.cpp: > #include <memory> > using namespace std; > > auto_ptr<int> get() { auto_ptr<int> ai(new int); return ai;} > int main() > { > const auto_ptr<int>& rai = get(); > > } > > Compilation: > /expor...ic_refer$>g++ -c autoptr.cpp > autoptr.cpp: In function `int main()': > autoptr.cpp:7: error: passing `const std::auto_ptr<int>' as `this' argument of `std::auto_ptr<_Tp>::operator std::auto_ptr_ref<_Tp1>() > [with _Tp1 = int, _Tp = int]' discards qualifiers como online reports: "ComeauTest.c", line 7: error: class "std::auto_ptr<int>" has no suitable copy constructor const auto_ptr<int>& rai = get(); > > Is it a bug? > It used to work with gcc 3.2. It also works with gcc 3.3.3 . Could you repost this in a forum like comp.lang.c++.moderated, and start a discussion about whether or not the code is well-formed?