shafik added inline comments.
================ Comment at: clang/test/AST/Interp/shifts.cpp:57 + //c >>= 999999; // expected-warning {{shift count >= width of type}} + //c <<= CHAR_BIT; // expected-warning {{shift count >= width of type}} + //c >>= CHAR_BIT; // expected-warning {{shift count >= width of type}} ---------------- This is not correct, the operands go through integral promotions first and the result is the promoted type of the left operand see [dcl.shift p1](https://eel.is/c++draft/expr.shift#1). Also see godbolt: https://godbolt.org/z/7qzKjojMb ================ Comment at: clang/test/AST/Interp/shifts.cpp:70 + i = 1 << (WORD_BIT - 1); // cxx17-warning-not {{sets the sign bit of the shift expression}} + i = -1 << (WORD_BIT - 1); // cxx17-warning {{shifting a negative signed value is undefined}} \ + // ref-cxx17-warning {{shifting a negative signed value is undefined}} ---------------- A negative left operand was made well-formed in C++20 I believe see godbolt: https://godbolt.org/z/7qzKjojMb My reference from above for `expr.shift/p1` also applies. Although a negative right operand is still UB. Also note shifting into the sign bit was made well-formed in C++11: https://stackoverflow.com/questions/19593938/is-left-shifting-a-negative-integer-undefined-behavior-in-c11#comment29091986_19593938 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136532/new/ https://reviews.llvm.org/D136532 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits