short - short也要转int啊

 

这可烦人了:

short i = 1, j = 2;
i += j; // warning C4244: '+=' : conversion from 'int' to 'short', possible loss of data (VC6 Warning Level 4)

还是VC6, cl /W3无上述警告,/W4才有。

gcc version 10.2.1 20210110 (Debian 10.2.1-6) -Wall 没有。

gcc -Wall -m32 -S t.cpp

movw  $0, -2(%ebp)
movw  $1, -4(%ebp)
movzwl  -2(%ebp), %edx
movzwl  -4(%ebp), %eax
addl  %edx, %eax
movw  %ax, -2(%ebp)

float呢?MOVSS — Move or Merge Scalar Single-Precision Floating-Point Value, subss. double是movsd.

https://www.riscfive.com/2022/04/28/risc-v-assembly-tutorial

posted @ 2022-12-07 15:56  华容道专家  阅读(22)  评论(0)    收藏  举报