So, in the upstream sources, we have this line
rc_c_max = allmem - (3 << 30);
Upstream which typically uses gcc, does things "as expected". allmem is uint64_t.
But with clang, it appears to assume "3" is 32 bit (or maybe signed) and the results are not "as expected". An easy fix for it is to change it to
rc_c_max = allmem - (3ULL << 30);
and everything works. Changing all the bare-interger shifts, by working out/guessing which needs to be corrected is tedious, is there a warning I can enable for clang to point this out? -Wall -Wextra does not complain about this line.
Output:
1/19/16 9:25:30.000 AM kernel[0]: allmem - (3 << 30) : 0x373333000 : 14817636352
1/19/16 9:25:30.000 AM kernel[0]: allmem - (3ULL << 30) : 0x273333000 : 10522669056
3has typesigned int. You should always be thinking about types when writing code containing shifts .