Closed kirk0830 closed 14 hours ago
It turns out to be an issue of int overflow. The following boxed code (as well as several other places doing the similar calculation)
may not work as expected, because nks2, nbands, npol & npwx all have type int, whose maximum value is 2^31-1 = 2147483647 on a machine with int defaulted to int32. Although the last term, sizeof(...) will return a size_t, given the evaluation of such arithmetic expression is left-to-right, it will not promote int to size_t until the last multiplication. That is, if the product nks2 nbands npol * npwx exceeds INT_MAX, the result would be wrong.
A quick solution is to move sizeof(...) to the first term in the chained multiplication.
Describe the bug
ecutwfc2000Ry.zip
Expected behavior
No response
To Reproduce
No response
Environment
No response
Additional Context
No response
Task list for Issue attackers (only for developers)