diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index be33eeb03d4..f987d8b9d0a 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -2384,12 +2384,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, __false_type) { + bool __notempty = __first != __last; for (; __first != __last; ++__first) #if __cplusplus >= 201103L emplace_back(*__first); #else push_back(*__first); #endif + if (__notempty) + { + if (begin() == end()) + __builtin_unreachable(); + } } // Called by list(n,v,a), and the range constructor when it turns out