Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion stl/inc/vector
Original file line number Diff line number Diff line change
Expand Up @@ -3195,7 +3195,10 @@ public:
_NODISCARD _CONSTEXPR20 size_type max_size() const noexcept {
constexpr auto _Diff_max = static_cast<size_type>(_STD _Max_limit<difference_type>());
const size_type _Ints_max = this->_Myvec.max_size();
if (_Ints_max > _Diff_max / _VBITS) { // max_size bound by difference_type limits

// Use a const bool to avoid warning C4127 "conditional expression is constant" with Defect Report P2280R4
const bool _Would_overflow = _Ints_max > _Diff_max / _VBITS;
if (_Would_overflow) { // max_size bound by difference_type limits
return _Diff_max;
}

Expand Down