From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B6D5B38518BA; Wed, 23 Nov 2022 19:09:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B6D5B38518BA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669230548; bh=N+B0Xy9RAdrH2Z1w5wwflf9xITbGxoTPGSXbZinFoe8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dswZWgqVvB+jw5rXnlTGk7LlVeOfuU0xeVvoWsmEXplaI6YhtptrliVEv3e8rIgFE wAIewy/Td+O8Fiq+Slnr8rkpIJqpJdflnHk4NNIp28vBRjSlF0azcs1ULuOG7ywFDy OLBWv2oOYtghnaMpCKsLefHsHz3CR1EwV7HJxuPQ= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/107846] [13 Regression] error: result of '8000 << 8' requires 22 bits to represent, but 'short int' only has 16 bits Date: Wed, 23 Nov 2022 19:09:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: diagnostic, needs-bisection X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: keywords cf_reconfirmed_on bug_status cf_known_to_work component target_milestone everconfirmed short_desc cf_gcctarget Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107846 Andrew Pinski 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 --- 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 =3D 8000; unsigned short f(int t) { if (t !=3D __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.=