https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108554

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jan de Cuveland from comment #2)
> So it is just that the static analyzer does not see that (to my
> understanding) "it" has to be a valid iterator and thus will always result
> in a non-empty node handle.

I thought that was the case, but it's actually a little more complicated. There
are some non-inline functions used by std::map when rebalancing the tree, and
the compiler doesn't know that they never return a null pointer (assuming valid
inputs, i.e. no past-the-end iterators, which is a precondition of those
functions anyway).

The patch above uses the returns_nonnull attribute so the compiler knows that
we always get a valid pointer back from those functions.

Reply via email to