Yes, I could have posted the backtrace as well: #0 __ubsan::__ubsan_handle_nonnull_arg_abort (Data=0x65cf6a00) at ../../../../../gcc/libsanitizer/ubsan/ubsan_handlers.cc:408 #1 0x5d74e3dc in equal<unsigned int> (__first2=<optimized out>, __last1=<optimized out>, __first1=<optimized out>) at /opt/gcc/gcc-5/include/c++/5.1.1/bits/stl_algobase.h:825 #2 __equal_aux<unsigned int const*, unsigned int const*> (__first2=<optimized out>, __last1=<optimized out>, __first1=<optimized out>) at /opt/gcc/gcc-5/include/c++/5.1.1/bits/stl_algobase.h:842 #3 equal<__gnu_cxx::__normal_iterator<unsigned int const*, std::vector<unsigned int> >, __gnu_cxx::_ _normal_iterator<unsigned int const*, std::vector<unsigned int> > > (__first2=..., __last1=..., __first1=...) at /opt/gcc/gcc-5/include/c++/5.1.1/bits/stl_algobase.h:1063 #4 operator==<unsigned int, std::allocator<unsigned int> > (__y=..., __x=...) at /opt/gcc/gcc-5/include/c++/5.1.1/bits/stl_vector.h:1513 ... template<> struct __equal<true> { template<typename _Tp> static bool equal(const _Tp* __first1, const _Tp* __last1, const _Tp* __first2) { return !__builtin_memcmp(__first1, __first2, sizeof(_Tp) * (__last1 - __first1)); } }; is seemingly where it ends up. On 28 May 2015 at 20:06, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote: > On 28 May 2015 at 18:26, Lars Gullik Bjønnes wrote: >> Is this is a known problem? > > No, I don't think so. > > At a guess, we're dispatching to memcmp for trivial types, but > shouldn't be doing that with null pointers. > > >> ------- >> #include <vector> >> >> int main() >> { >> std::vector<unsigned> a; >> std::vector<unsigned> b; >> return a == b; >> } >> --------- >> >> $ g++ -fsanitize=nonnull-attribute empty_vectors.cpp >> $ /a.out >> usr/include/c++/5.1.1/bits/stl_algobase.h:825:28: runtime error: null >> pointer passed as argument 1, which is declared to never be null >> /usr/include/c++/5.1.1/bits/stl_algobase.h:825:28: runtime error: null >> pointer passed as argument 2, which is declared to never be null >> >> $ g++ --version >> g++ (GCC) 5.1.1 20150422 (Red Hat 5.1.1-1) >> (fc22) >> >> I got the same with: >> $ /opt/gcc/gcc-5/bin/g++ --version >> g++ (GCC) 5.1.1 >> >> -- >> Lgb -- Lgb