[Bug c++/57870] New: Internal compiler error in use of emplace
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57870 Bug ID: 57870 Summary: Internal compiler error in use of emplace Product: gcc Version: 4.7.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: eyakubovich at gmail dot com In the following code, S lacks a constructor that accepts an int. Subsequently, g++ crashes on use of emplace: #include struct S { int x; friend bool operator<(S const&, S const&) { return false; } }; int main() { std::priority_queue q; q.emplace(1); return 0; } A similar problem occurs with use of std::vector, however a correct error is first issued: #include struct S { int x; }; int main() { std::vector q; q.emplace(q.begin(), 1); return 0; }
[Bug c++/44186] New: Wrong code generated with -O2 and above
This is a stripped down code from proposed Boost.Move library. Asserts don't fire with -O0 and -O1 but do with -O2 and -O3 #include template class rv : public T { rv(); ~rv(); rv(rv const&); void operator=(rv const&); }; template rv& move(T& x) { return *static_cast* >(&x); } //A movable class class movable { movable(movable &); movable& operator=(movable&); public: operator rv&() { return *reinterpret_cast< rv* >(this); } operator const rv&() const { return *reinterpret_cast* >(this); } private: int value_; public: movable() : value_(1){} //Move constructor and assignment movable(rv& m) { value_ = m.value_; m.value_ = 0; } movable & operator=(rv& m) { value_ = m.value_; m.value_ = 0; return *this; } bool moved() const //Observer { return value_ == 0; } }; movable function(movable m) { return movable(move(m)); } int main() { { movable m; movable m2(move(m)); assert(m.moved()); assert(!m2.moved()); } { movable m; movable m3(function(movable(move(m; assert(m.moved()); assert(!m3.moved()); } { movable m; movable m4(function(move(m))); assert(m.moved()); assert(!m4.moved()); } return 0; } -- Summary: Wrong code generated with -O2 and above Product: gcc Version: 4.4.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: eyakubovich at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44186
[Bug c++/44187] New: Wrong code generated with -O2 and above
This is a stripped down code from proposed Boost.Move library. Asserts don't fire with -O0 and -O1 but do with -O2 and -O3 #include template class rv : public T { rv(); ~rv(); rv(rv const&); void operator=(rv const&); }; template rv& move(T& x) { return *static_cast* >(&x); } //A movable class class movable { movable(movable &); movable& operator=(movable&); public: operator rv&() { return *reinterpret_cast< rv* >(this); } operator const rv&() const { return *reinterpret_cast* >(this); } private: int value_; public: movable() : value_(1){} //Move constructor and assignment movable(rv& m) { value_ = m.value_; m.value_ = 0; } movable & operator=(rv& m) { value_ = m.value_; m.value_ = 0; return *this; } bool moved() const //Observer { return value_ == 0; } }; movable function(movable m) { return movable(move(m)); } int main() { { movable m; movable m2(move(m)); assert(m.moved()); assert(!m2.moved()); } { movable m; movable m3(function(movable(move(m; assert(m.moved()); assert(!m3.moved()); } { movable m; movable m4(function(move(m))); assert(m.moved()); assert(!m4.moved()); } return 0; } -- Summary: Wrong code generated with -O2 and above Product: gcc Version: 4.4.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: eyakubovich at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44187