]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Tell GCC what basic_string::_M_is_local() means [PR109299]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 28 Mar 2023 09:50:40 +0000 (10:50 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 28 Mar 2023 21:59:51 +0000 (22:59 +0100)
commit00ac6fa3f2a54fb9cc17b7b7f51eae3c6bf7a1bd
tree8ec79efc802f1d6916df6cfc63559fd388be19dd
parent1729d03652a700342f23c2fa6f249d9dec5e9e02
libstdc++: Tell GCC what basic_string::_M_is_local() means [PR109299]

This avoids a bogus warning about overflowing a buffer, because GCC
can't tell that we don't copy into the buffer unless it fits. By adding
a __builtin_unreachable() hint we inform the compiler about the
invariant that the buffer is only used when it's big enough.

This can also improve codegen, by eliminating dead code that GCC
couldn't tell was unreachable.

libstdc++-v3/ChangeLog:

PR libstdc++/109299
* include/bits/basic_string.h (basic_string::_M_is_local()): Add
hint for compiler that local strings fit in the local buffer.

(cherry picked from commit bf78b43873b0b7e8f9a430df38749b8b61f9c9b8)
libstdc++-v3/include/bits/basic_string.h
This page took 0.05961 seconds and 6 git commands to generate.