Containers (CTR)
- CTR50-CPP. Guarantee that container indices and iterators are within the valid range
- CTR51-CPP. Use valid references, pointers, and iterators to reference elements of a container
- CTR52-CPP. Guarantee that library functions do not overflow
- CTR53-CPP. Use valid iterator ranges
- CTR54-CPP. Do not subtract iterators that do not refer to the same container
- CTR55-CPP. Do not use an additive operator on an iterator if the result would overflow
- CTR56-CPP. Do not use pointer arithmetic on polymorphic objects
- CTR57-CPP. Provide a valid ordering predicate
- CTR58-CPP. Predicate function objects should not be mutable
The following rules from the SEI CERT C Coding Standard also apply in C++:
- ARR30-C. Do not form or use out-of-bounds pointers or array subscripts
- ARR37-C. Do not add or subtract an integer to a pointer to a non-array object
- ARR38-C. Guarantee that library functions do not form invalid pointers
- ARR39-C. Do not add or subtract a scaled integer to a pointer
Information for Editors
To have a new guideline automatically listed above be sure to label it ctr and rule .
Risk Assessment Summary
| Rule | Severity | Likelihood | Detectable | Repairable | Priority | Level |
|---|---|---|---|---|---|---|
| CTR50-CPP | High | Likely | No | No | P9 | L2 |
| CTR51-CPP | High | Probable | No | No | P6 | L2 |
| CTR52-CPP | High | Likely | No | No | P9 | L2 |
| CTR53-CPP | High | Probable | No | No | P6 | L2 |
| CTR54-CPP | Medium | Probable | No | No | P4 | L3 |
| CTR55-CPP | High | Likely | No | No | P9 | L2 |
| CTR56-CPP | High | Likely | No | No | P9 | L2 |
| CTR57-CPP | Low | Probable | No | No | P2 | L3 |
| CTR58-CPP | Low | Likely | Yes | No | P6 | L2 |


