https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125236
Bug ID: 125236
Summary: RFE: detect common mistakes in usage of C++ std
library
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: analyzer
Assignee: dmalcolm at gcc dot gnu.org
Reporter: dmalcolm at gcc dot gnu.org
CC: redi at gcc dot gnu.org
Blocks: 97110
Target Milestone: ---
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)
* std::vector vs std::string vs std::deque vs std::list vs std::forward_list,
etc
Use of stale iterator after resize
==================================
std::vector vs std::string, etc
Use of stale iterator after dtor of underlying dtor
===================================================
std::vector vs std::string, etc
Null deref of smart pointers
============================
std::unique_ptr, std::shared_ptr
All of the above with/without hardening (see
https://en.cppreference.com/cpp/standard_library#Standard_library_hardening )
More ideas welcome.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97110
[Bug 97110] [meta-bug] tracker bug for supporting C++ in -fanalyzer