[Bug c++/60081] Internal compiler error: Error reporting routines re-entered.
stanislav.manilov at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Apr 30 12:29:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60081
--- Comment #4 from Stan Manilov <stanislav.manilov at gmail dot com> ---
Here is a simple way to reproduce the bug:
==============================
#include <vector>
#include <memory>
int main() {
std::vector<std::unique_ptr<int>> v;
std::unique_ptr<int> px(new int (1));
v.push_back(px);
}
==============================
There is a bug in the code: push_back tries to copy the given element by
default. This should return an error along the lines of "Call to deleted copy
constructor of std::unique_ptr". Instead it gives ICE.
A solution to the bug in the code is to explicitly call std::move like so:
==============================
#include <vector>
#include <memory>
int main() {
std::vector<std::unique_ptr<int>> v;
std::unique_ptr<int> px(new int (1));
v.push_back(std::move(px));
}
==============================
More information about the Gcc-bugs
mailing list