This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

Re: libstdc++ of g++ 3.4.x: std::swap and std::auto_ptr causes compilationerrors


Paolo Carlini wrote:

Vinzenz Feenstra wrote:

I had no problems with 3.3.x and 3.2.x, other versions I didn't test, but in my opinion it is strange.


If true, would be definitely strange, since AFAIK, nothing changed in this area recently.

Can you send over a short snippet that now leads (correctly) to compilation errors and didn't earlier?

Thanks,
Paolo.

Ok


I mentioned the problem while compiling OpenC++ and OpenC++ Core there is a file called MetacompilerConfiguration.h which uses auto_ptr and swap
but I made an other example which works with 3.3 and don't work with 3.4


// Example:
#include <memory>
#include <algorithm>
#include <iostream>

class TestClass
{
   int value;
 public:
    TestClass(int val_):value(val_){}
   ~TestClass(){}
    void Print(){ std::cout << "My Value is: " << value << std::endl;}
};


int main() {

 std::auto_ptr<TestClass> A(new TestClass(0));
 std::auto_ptr<TestClass> B(new TestClass(1));

 A->Print();
 B->Print();

std::cout << "Swapping A and B " << std::endl;

std::swap(A ,B);

 A->Print();
 B->Print();

 return 0;
}
// Example ends


I had a view on bits/stl_algobase.h of 3.3 and 3.4 this is the difference of them:


std::swap of 3.3:

template<typename _Tp>
inline void
swap(_Tp& __a, _Tp& __b)
{
// concept requirements
__glibcpp_function_requires(_SGIAssignableConcept<_Tp>)
_Tp __tmp = __a;
__a = __b;
__b = __tmp;
}


std::swap of 3.4
template<typename _Tp>
inline void
swap(_Tp& __a, _Tp& __b)
{
// concept requirements
__glibcpp_function_requires(_SGIAssignableConcept<_Tp>)
const _Tp __tmp = __a; // <-- this is the problem in my opinion
__a = __b;
__b = __tmp;
}



BR


Vinzenz


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