[clang] [clang] Emit bad shift warnings (PR #70307)
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 18 01:51:03 PDT 2024
alexfh wrote:
Just to confirm: is this the intentional outcome of this patch?
https://gcc.godbolt.org/z/Kf9YK1qM3
```
enum {
a = 1<<12,
b = (-1)<<13
};
```
```
<source>:3:9: error: expression is not an integral constant expression
3 | b = (-1)<<13
| ^~~~~~~~
<source>:3:13: note: left shift of negative value -1
3 | b = (-1)<<13
| ^
```
Though technically, it's UB before C++20, the diagnostic - "expression is not an integral constant expression" - doesn't sound helpful (how is it not constant or not integral?). And what's worse, is that it's an error rather than a warning that can be disabled.
https://github.com/llvm/llvm-project/pull/70307
More information about the cfe-commits
mailing list