You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the Sequence class uses the type alias using signed_index_type = std::make_signed_t<std::size_t>; to represent indices. This choice can potentially lead to undefined behavior because of overflows, converting between signed and unsigned types, especially with large values, can result in incorrect indexing and arithmetic errors.
We should replace the signed index type with an unsigned
using index_type = std::size_t;
Additionally, we need to implement overflow protection to handle scenarios where the sequence index might wrap around its maximum value. In a CircularBuffer implementation, it is assumed that:
sequence + 1 > sequence
To maintain this invariant, we should introduce overflow checks and handle them appropriately to prevent undefined behavior.
The text was updated successfully, but these errors were encountered:
Currently, the
Sequence
class uses the type aliasusing signed_index_type = std::make_signed_t<std::size_t>;
to represent indices. This choice can potentially lead to undefined behavior because of overflows, converting between signed and unsigned types, especially with large values, can result in incorrect indexing and arithmetic errors.We should replace the signed index type with an unsigned
Additionally, we need to implement overflow protection to handle scenarios where the sequence index might wrap around its maximum value. In a
CircularBuffer
implementation, it is assumed that:sequence + 1 > sequence
To maintain this invariant, we should introduce overflow checks and handle them appropriately to prevent undefined behavior.
The text was updated successfully, but these errors were encountered: