Out of bound access of C++ standard library containers
Index of C++ Standard template Library (STL) container out of bounds during container access using standard operators or methods
Since R2026a
Description
This defect occurs if an out of bounds element of these containers are accessed using one of the listed operators or methods:
std::array—std::array::operator[],std::array::front,std::array::backstd::vector—std::vector::operator[],std::vector::push_back,std::vector::pop_backstd::deque—std::deque::operator[],std::deque::push_back,std::deque::pop_back,std::deque::push_front,std::deque::pop_front
Risk
Accessing a container outside its bounds is undefined behavior.
Fix
To fix this issue, check the bounds of a container before accessing them. When
iterating over containers, avoid using c-style for loops. Instead,
use range based for loops that manages the bounds
automatically.
Examples
Result Information
| Group: Programming |
| Language: C++ |
| Default: On |
Command-Line Syntax:
CONTAINER_STD_LIB
|
| Impact: High |
PQL Name:
std.defects.CONTAINER_STD_LIB
|
Version History
Introduced in R2026a
See Also
Find defects
(-checkers) | Array access out of bounds
Topics
- Interpret Polyspace Bug Finder Results in Polyspace Platform User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Polyspace Results Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)