From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 437F6385189D; Wed, 23 Nov 2022 18:26:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 437F6385189D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669227983; bh=WKjhuioLjaag5/9ldDc4LU0wXbjJ6zaim7BT2bsBix8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hJlVKUXMCJ8xRuxJeOvJi/snK1iPwd+7ltkK/jtWjvGDv1sC4xOUGKp2SEBGeec2o cVDkEcxiYNTSNsECg7ZmVg1XAKXmW0grYTOUNtp+m7Nh5cp5pBCLl2BujoSPrtwL7h MIq368tpbuRrbMPoB4srY0lAKkUjGYAX9jqUJLQ8= From: "david.faust at oracle dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/107846] error: result of '8000 << 8' requires 22 bits to represent, but 'short int' only has 16 bits Date: Wed, 23 Nov 2022 18:26:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: david.faust at oracle dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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 --- Comment #1 from David Faust --- I think this is a bug in the test itself (or with these macros from libbpf). libbpf/src/bpf_endian.h #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) In tools/testing/selftests/bpf/progs/test_tc_tunnel.c: static const int cfg_port =3D 8000; static const int cfg_udp_src =3D 20000; ... then at e.g. line 276 if (tcph.dest !=3D __bpf_constant_htons(cfg_port)) return TC_ACT_OK; Expanding this __bpf_constant_htons macro: __bpf_constant_htons (cfg_port) __bpf_constant_htons (8000) ((__u16)(8000) << (16-(0+1)*8) >> (16-8) << (1*8) ((__u16)(8000) << (16-(1)*8) >> (8) << 8) ((__u16)(8000) << (8) >> 8 << 8 ((__u16)(8000) << 8) ...which raises the shift-overflow warning.=