Why, when I write this code:

size_t VRamSize = 2048 * 1024 * 1024; 

do I get the warning "Constant overflow" ?

warning C4307: '*': integral constant overflow

size_t I have unsigned long long (the largest type), it has a range, attention,

0 to 18,446,744,073,709,551,615

2048 * 1024 * 1024 = 2147483648 (count how much less characters).

What does this warning mean?

    1 answer 1

    In the process of multiplication itself, you multiply constants of type int , and only then bring the result to type ull. So use the appropriate suffixes (I don’t know what they are exactly in the studio), such as 1024llu .

    Or you can explicitly cast the type immediately size_t(1024)*1024*2048 .