Reputation: 2583
The following code compiles fine when using STLPort:
std::vector<Engine::Screen::IOverlay*> Overlays;
auto TestOverlay=new Engine::Screen::Overlay();
Overlays.push_back(TestOverlay);
However when compiling with libstdc++ it's trying to use move constructor for some reason:
error : cannot bind 'Engine::Screen::IOverlay*' lvalue to 'Engine::Screen::IOverlay*&&' ...\android-ndk-r8\sources\cxx-stl\gnu-libstdc++\include\bits\move.h
This is a very basic example but this issue occurs through out the application for all local pointers when using push_back.
Error occurs in move.h:
template<typename _Tp>
inline typename std::remove_reference<_Tp>::type&&
move(_Tp&& __t)
{ return __t; }
Example 2 (Another basic test I wrote:)
class TestClass {};
auto TestInstance=new TestClass;
std::vector<TestClass*> TestVector;
TestVector.push_back(TestInstance);
I compiled with ndk r8: -std=c++11 -D__STDC_INT64__
Upvotes: 3
Views: 830
Reputation: 361612
It seems there are two bugs in the compiler. First it incorrectly callspush_back(T&&)
which then attempts to move the object, which is implemented incorrecty:
template<typename _Tp>
inline typename std::remove_reference<_Tp>::type&&
move(_Tp&& __t)
{ return __t; }
It should be implemented as:
template<class _Tp>
typename remove_reference<_Tp>::type&&
move(_Tp&& __t) noexcept //noexcept should be here!
{
return static_cast<typename remove_reference<_Tp>::type&&>(__t);
}
which means your compiler is showing up two bugs in this context:
push_back(T&&)
.std::move
which version of what compiler are you using?
Upvotes: 4