I have the following snippet:
#include <iostream>
void func(uint64_t i) { std::cout<<i<<std::endl; }
class A{
public:
A(uint64_t i){ std::cout<<i<<std::endl; }
};
int main(int /*argc*/, char* /*argv*/[]) {
func(1024 * 1024 * 1024 * 1024 * 1024ull); // clang [-Winteger-overflow]: Overflow in expression; result is 0 with type 'int'
A a(1024 * 1024 * 1024 * 1024 * 1024ull); // no error
return 0;
}
I know I should have written 1024ull * 1024 * ..., but I am wondering why my compiler (clang) only throws the overflow error at the line with func, and is not aware of the problem in the constructor