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
Underflow flagged in the Coverity scan due to variable type. However, it doesn't cause any functional issues or program failures.
Version
Example illustrated using v2021.2.5, but the issue should exists in all versions.
Environment
Environment set-up is not required.
Observed Behavior
The variable s is defined as segment_index_typeLink, which is an alias for std::size_tLink, a long unsigned integer type.
The do-while loop executes for any initial value of s, and s reaches 0, underflow occurs. s will wrap around to its maximum representable value, ULONG_MAX.
However, since the loop condition is (s = 0 > 0), which evaluates to false, loop terminates. Therefore, despite the occurrence of underflow, the program's behavior should remain as expected.
Expected Behavior
Suggested modification:
voidclear() {
...
do {
...
} while (s>0&&s-->0);
...
}
Adding another condition check (s > 0) prior will prevent the execution of s-- when s is 0, but keeping the main loop executing for the case s is 0.
ShinYanKokIntel
changed the title
Coverity issue captured on concurrent_hash_map.h
[Coverity] Underflow error captured on concurrent_hash_map.h in coverity scan
Feb 14, 2025
Summary
Underflow flagged in the Coverity scan due to variable type. However, it doesn't cause any functional issues or program failures.
Version
Example illustrated using v2021.2.5, but the issue should exists in all versions.
Environment
Environment set-up is not required.
Observed Behavior
The variable
s
is defined assegment_index_type
Link, which is an alias forstd::size_t
Link, a long unsigned integer type.The do-while loop executes for any initial value of
s
, ands
reaches 0, underflow occurs.s
will wrap around to its maximum representable value,ULONG_MAX
.However, since the loop condition is
(s = 0 > 0)
, which evaluates tofalse
, loop terminates. Therefore, despite the occurrence of underflow, the program's behavior should remain as expected.Expected Behavior
Suggested modification:
Adding another condition check
(s > 0)
prior will prevent the execution ofs--
whens
is0
, but keeping the main loop executing for the cases
is0
.Steps To Reproduce
Compilation not required. Link to line
The text was updated successfully, but these errors were encountered: