PVS-Studio 6.26 Released
This new release included many interesting improvements related to analysis of C and C++ code, about which we'd like to tell our users.
PVS-Studio 6.26 Released
by Andrey Karpov
From the article:
A developer believes that this is a bug in the compiler. Nevertheless, it is the author of the code who is wrong. The function does not work correctly due to the fact that undefined behavior occurs in it. The compiler follows that in the
r
variable a certainsum
is calculated. Overflow of ther
variable must not happen. Otherwise, it is undefined behavior, which doesn't have to be considered or taken into account by a compiler. So, the compiler thinks that since the value of r variable after ending the loop cannot be negative, thenr & 0x7fffffff
operation is not needed to reset the sigh bit and the compiler just returns the value ofr
variable from the function.