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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2026-05-08
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to David Malcolm from comment #0)
> I'm filing this RFE as a catch-all for -fanalyzer detecting common usage
> mistakes in the C++ std library.   This might require implementing PR 106386
> (to reuse libstdc++ assertions in -fanalyzer).
> 
> Ideas:
> 
> Out of bounds access to sequence containers
> ===========================================
> combinations of:
>   * access method: "operator[]" vs "at()" vs "front()", "back()",
> "pop_front()" and "pop_back" (when empty)

The behaviour of at() is fully specified for out of bounds access, it checks
and throws an exception. So maybe that's not worth checking (it's also not
commonly used anyway).

>   * std::vector vs std::string vs std::deque vs std::list vs
> std::forward_list, etc
> 
> Use of stale iterator after resize
> ==================================

The term in the standard is "invalid" rather than stale.

Not only iterators, but pointers too. As a specific (and fairly common example)
using the result of std::string::c_str() or std::string::data() after the
string has been reallocated or deallocated accesses a dangling pointer.

> Null deref of smart pointers
> ============================
> std::unique_ptr, std::shared_ptr

I'm not sure how common these really are.

Reply via email to