http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61086
Bug ID: 61086
Summary: ubsan detects undefined behaviour in the standard
library
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: chris at detrino dot org
The following program compiled with clang++ -fsanitize=undefined reveals
undefined behavior.
Program:
#include <array>
#include <vector>
int main()
{
std::vector<int> v;
std::array<int, 2> array{{0, 1}};
v.insert(v.end(), array.begin(), array.end());
}
Errors:
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/bits/stl_iterator.h:745:26:
runtime error: reference binding to null pointer of type 'typename
_PTraits::element_type' (aka 'int')
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/bits/ptr_traits.h:169:31:
runtime error: reference binding to null pointer of type 'typename
__ptrtr_not_void<element_type>::__type' (aka 'int')
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/bits/move.h:136:31:
runtime error: reference binding to null pointer of type 'int'