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__
It seems there are two bugs in the compiler. First it incorrectly calls
push_back(T&&)which then attempts to move the object, which is implemented incorrecty:It should be implemented as:
which means your compiler is showing up two bugs in this context:
push_back(T&&).std::movewhich version of what compiler are you using?