[Bug libstdc++/86292] New: Missing exception safety when constructing vector from input iterator pair
kristian.spangsege at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Jun 23 19:58:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86292
Bug ID: 86292
Summary: Missing exception safety when constructing vector from
input iterator pair
Product: gcc
Version: 8.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: kristian.spangsege at gmail dot com
Target Milestone: ---
Created attachment 44316
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44316&action=edit
Code to trigger the bug
When constructing a `std::vector` from a pair of input iterators
(`std::input_iterator_tag`), and the copy constructor for the value type
throws, already constructed copies will never be destroyed. I.e., the mentioned
vector constructor is not exception safe under these circumstances.
See the attached code for a way to trigger and reveal the problem.
The expectation is that it should output `0` (no instances of `X` remain at
exit), but it outputs `1`, meaning that one `X` object was leaked.
I tried this with GCC version 8.0.1 and 5.5.0 on Linux Mint 18.1.
More information about the Gcc-bugs
mailing list