Closed
Description
In the following program there are two similar signed integer overflows:
#include <cstdint>
void func(uint64_t) {}
struct A {
A(uint64_t){}
};
int main() {
func(1024 * 1024 * 1024 * 1024 * 1024ull); // warning, ok
A a(1024 * 1024 * 1024 * 1024 * 1024ull); // no warning in Clang!
}
The one in calling func
is detected by Clang.
But the other one in calling A::A
does not, even with -Wall -Wextra
flags. At the same time both GCC and MSVC reports the warning here as well. Online demo: https://gcc.godbolt.org/z/6vGT33q1W
Related discussion: https://stackoverflow.com/q/73962573/7325599