https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54924
--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> --- As a heads up, with the patch for bug 79234 applied and with -Wsystem-headers explicitly specified GCC issues the warnings below (the -Warray-bounds is printed even without the patch). Unfortunately, with the default -Wno-system-headers, warnings from std::string and the rest of libstdc++ headers are suppressed. $ cat t.C && /build/gcc-79234/gcc/xg++ -B /build/gcc-79234/gcc -nostdinc++ -I /build/gcc-79234/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu -I /build/gcc-79234/x86_64-pc-linux-gnu/libstdc++-v3/include -I /src/gcc/79234/libstdc++-v3/libsupc++ -I /src/gcc/79234/libstdc++-v3/include/backward -I /src/gcc/79234/libstdc++-v3/testsuite/util -L /build/gcc-79234/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -O2 -S -Wall -Wsystem-headers t.C #include <string> std::string s ("abc", 5); In file included from /build/gcc-79234/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_algobase.h:66:0, from /build/gcc-79234/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h:39, from /build/gcc-79234/x86_64-pc-linux-gnu/libstdc++-v3/include/string:40, from t.C:1: /build/gcc-79234/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_iterator_base_funcs.h: In function ‘(static initializers for t.C)’: /build/gcc-79234/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_iterator_base_funcs.h:104:21: warning: array subscript is above array bounds [-Warray-bounds] return __last - __first; ~~~~~~~^~~~~~~~~ In file included from /build/gcc-79234/x86_64-pc-linux-gnu/libstdc++-v3/include/string:40:0, from t.C:1: In static member function ‘static std::char_traits<char>::char_type* std::char_traits<char>::copy(std::char_traits<char>::char_type*, const char_type*, std::size_t)’, inlined from ‘static void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_S_copy(_CharT*, const _CharT*, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /build/gcc-79234/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:324:21, inlined from ‘void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_construct(_InIterator, _InIterator, std::forward_iterator_tag) [with _FwdIterator = const char*; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’, inlined from ‘void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_construct(_InIterator, _InIterator) [with _InIterator = const char*; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /build/gcc-79234/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:220:23, inlined from ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /build/gcc-79234/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:486:21, inlined from ‘void __static_initialization_and_destruction_0(int, int)’ at t.C:3:24, inlined from ‘(static initializers for t.C)’ at t.C:3:25: /build/gcc-79234/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h:292:66: warning: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ reading 5 bytes from a region of size 4 [-Wstringop-overflow=] return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n)); ^