Is there a GCC warning that detects bit shift operations on signed types?

后端 未结 2 1266
醉话见心
醉话见心 2021-01-11 11:11

If I read the C++ ISO specification (sections 5.8.2 and 5.8.3) right, the right-shift of negative signed types is implementation specific and the left-shift undefined behavi

2条回答
  •  天命终不由人
    2021-01-11 11:48

    The GCC documentation is here.

    The answer appears to be "no", there's not any warning option for what you want.

    I don't know why, but I'd guess that there's just so much code out there that uses this that it would be too noisy. C may not define arithmetic shifts, but pretty much all CPUs do it the same way, these days, so most people assume it is defined that way.

提交回复
热议问题