This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/64147] New: vector resize() fails for non-copyable type
- From: "ebf at users dot sourceforge.net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 02 Dec 2014 08:14:33 +0000
- Subject: [Bug libstdc++/64147] New: vector resize() fails for non-copyable type
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64147
Bug ID: 64147
Summary: vector resize() fails for non-copyable type
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: ebf at users dot sourceforge.net
Compiling the below program with -std=c++11 fails, "error: call to deleted
constructor of 'Foo'".
This seems incorrect since C++11 explicitly added a new single argument vector
resize method that is supposed to default-construct elements rather than copy
them.
---
#include <vector>
class Foo {
public:
Foo() {}
Foo(const Foo&) = delete;
};
int main() {
std::vector<Foo> vec;
vec.resize(42); // error: call to deleted constructor of 'Foo'
}
---
By contrast, the following program using the vector size constructor works ok:
---
#include <vector>
class Foo {
public:
Foo() {}
Foo(const Foo&) = delete;
};
int main() {
std::vector<Foo> vec(42); // compiles fine
}