隐式转换:以下警告有效吗?

Implicit conversion: is the following warning valid?

这个问题Implicit type conversion rules in C++ operators(和其他几个)状态

If either is long long unsigned int the other is promoted to long long unsigned int

但是,如果我在 MSVC 下执行以下操作:

unsigned int a = <some expression>;
unsigned long long b = a << 32ULL;

第二行生成以下警告:

warning C4293: '<<': shift count negative or too big, undefined behavior

32ULL 是一个 64 位无符号值,因此根据隐式转换规则,这应该意味着 a 也被转换为 unsigned long long。因此,我将 64 位值移动 32 位,这显然是一个定义明确的操作。

是 MSVC 有问题还是我的逻辑有缺陷?

轮班不做所谓的"usual arithmetic conversions",也就是你引用的规则。 They only perform integral promotions. The result of a shift is of the same type as the promoted left operand.