https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92659
Bug ID: 92659
Summary: Suggestions for bitshift
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jg at jguk dot org
Target Milestone: ---
Could GCC suggest for C/C++ the code change?
#include <stddef.h>
size_t i = 1 << 32;
#1 with x86-64 gcc (trunk)
<source>:2:14: warning: left shift count >= width of type
[-Wshift-count-overflow]
2 | size_t i = 1 << 32;
| ~~^~~~~
Compiler returned: 0
It could output:
<source>:2:14: warning: left shift count >= width of type
[-Wshift-count-overflow]
2 | size_t i = 1 << 32;
| ~~^~~~~
| size_t i = 1 << 32;
| ~~^~~~~
| 1UL << 32;