问题
Why i got warning on this code:
#include <cstdint>
int main()
{
int i = 1;
int64_t i64;
i64 = 1 << i;
}
warning C4334: '<<' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
but not on this:
#include <cstdint>
int main()
{
int i = 1;
int64_t i64 = 1 << i;
}
? Tested on vs2013/2015.
回答1:
I see the same discrepancy with vs2012. I don't think that there is a good reason for it - hopefully the warning will be emitted in both cases in a newer version of Visual C++.
回答2:
MSVS 2015 Upd.2: Second case (on initialization) will trigger C4334 warning.
来源:https://stackoverflow.com/questions/31558314/visual-studio-warning-c4334-on-assignment-but-not-on-initialization