[clang] [clang] Emit bad shift warnings (PR #70307)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 11 06:49:38 PST 2024


================
@@ -426,7 +426,7 @@ void dr081(void) {
   /* Demonstrate that we don't crash when left shifting a signed value; that's
    * implementation defined behavior.
    */
- _Static_assert(-1 << 1 == -2, "fail"); /* Didn't shift a zero into the "sign bit". */
+ _Static_assert(-1 << 1 == -2, "fail"); /* expected-warning {{shifting a negative signed value is undefined}} */
----------------
AaronBallman wrote:

Please fix the comment above; it's no longer implementation-defined behavior, it's undefined since C99

https://github.com/llvm/llvm-project/pull/70307


More information about the cfe-commits mailing list