https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107846
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic, needs-bisection
Last reconfirmed| |2022-11-23
Status|UNCONFIRMED |NEW
Known to work| |11.1.0, 12.1.0, 12.2.0,
| |9.1.0
Component|target |c
Target Milestone|--- |13.0
Ever confirmed|0 |1
Summary|error: result of '8000 << |[13 Regression] error:
|8' requires 22 bits to |result of '8000 << 8'
|represent, but 'short int' |requires 22 bits to
|only has 16 bits |represent, but 'short int'
| |only has 16 bits
Target|bpf |
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Short testcase:
typedef unsigned short __u16;
#define ___bpf_mvb(x, b, n, m) ((__u##b)(x) << (b-(n+1)*8) >> (b-8) << (m*8))
#define ___bpf_swab16(x) ((__u16)( \
___bpf_mvb(x, 16, 0, 1) | \
___bpf_mvb(x, 16, 1, 0)))
# define __bpf_constant_htons(x) ___bpf_swab16(x)
static const int cfg_port = 8000;
unsigned short f(int t)
{
if (t != __bpf_constant_htons (cfg_port))
return 1;
return 0;
}
--- CUT ---
This is definitely a bug in GCC though there might be a dup.
the line info is also missing ...
Note this only happens at -O1 and also a regression from GCC 12 even.