diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2023-01-26 10:55:28 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2023-01-26 13:38:22 +0000 |
commit | 3376467ce090aa0966d59ca3aea35db4f17a4b47 (patch) | |
tree | e1ef41d1f1965baf9e07254bf777027c6b357efd /gcc | |
parent | 93e2bf51dedd0870b78b770b72e34b15a7a0d14a (diff) | |
download | gcc-3376467ce090aa0966d59ca3aea35db4f17a4b47.zip gcc-3376467ce090aa0966d59ca3aea35db4f17a4b47.tar.gz gcc-3376467ce090aa0966d59ca3aea35db4f17a4b47.tar.bz2 |
libstdc++: Add returns_nonnull to non-inline std::map detail [PR108554]
std::map uses a non-inline function to rebalance its tree and the
compiler can't see that it always returns a valid pointer (assuming
valid inputs, which is a precondition anyway). This can result in
-Wnull-derefernce warnings for valid code, because the compiler thinks
there is a path where the function returns null.
Adding the returns_nonnull attribute tells the compiler that is can't
happen. While we're doing that, we might as well also add a nonnull
attribute to the rebalancing functions too.
libstdc++-v3/ChangeLog:
PR libstdc++/108554
* include/bits/stl_tree.h (_Rb_tree_insert_and_rebalance): Add
nonnull attribute.
(_Rb_tree_rebalance_for_erase): Add nonnull and returns_nonnull
attributes.
* testsuite/23_containers/map/modifiers/108554.cc: New test.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions