https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92642
Bug ID: 92642
Summary: Enhance shift-count-overflow output
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 g++ enhance this warning ?
Suggestion:
A) Include the number of bits being shifted
B) Include the type of the value being shifted.
C) Include the size in bits of the type in (B).
#1 with x86-64 gcc (trunk)
<source>:2:15: warning: left shift count >= width of type
[-Wshift-count-overflow]
2 | size_t big = 1<<41;
| ~^~~~
Compiler returned: 0
Suggestion:
#1 with x86-64 gcc (trunk)
<source>:2:15: warning: left shift count '41' >= width of type 'int' (32bit)
[-Wshift-count-overflow]
2 | size_t big = 1<<41;
| ~^~~~
Compiler returned: 0
Code:
#include <stdio.h>
size_t big = 1<<41;