From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A0E0D38582BE; Wed, 6 Mar 2024 13:56:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0E0D38582BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709733364; bh=8woRCJxm9ttUN0qthMCPeudB8IzrWWsARFCTVpsKQ9w=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OL8nvqHbMRrfbLAUYy/q6Eb+u6MDX1TmJOO3N+NpXMwGIHz+8IrvvqTq0r9r8gjOm 8O5RULJDydobA75FnUUll5fXdwXi2HrdYZa56vVtmQC0zXKxnFiWTaFb9soULhrVir WIJGz0VEWx4EXHpEZeQigiccRKpoB8r0fPAIOTnE= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/105533] UBSAN: gcc/expmed.cc:3272:26: runtime error: signed integer overflow: -9223372036854775808 - 1 cannot be represented in type 'long int' Date: Wed, 06 Mar 2024 13:56:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org 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=3D105533 --- Comment #8 from Jakub Jelinek --- The same function already does offset +=3D pop->off * BITS_PER_UNIT; a few lines earlier, so I think doing it here is fine as well. Or yet another option is to cast pop->off or op->off to offset_int first an= d do the left shift in offset_int type where it is well defined. 2024-03-06 Jakub Jelinek PR middle-end/105533 * tree-ssa-sccvn.cc (ao_ref_init_from_vn_reference) : Multiple op->off by BITS_PER_UNIT instead of shifting it left by LOG2_BITS_PER_UNIT. --- gcc/tree-ssa-sccvn.cc.jj 2024-02-28 22:57:18.318658827 +0100 +++ gcc/tree-ssa-sccvn.cc 2024-03-06 14:52:16.819229719 +0100 @@ -1221,7 +1221,7 @@ ao_ref_init_from_vn_reference (ao_ref *r if (maybe_eq (op->off, -1)) max_size =3D -1; else - offset +=3D op->off << LOG2_BITS_PER_UNIT; + offset +=3D op->off * BITS_PER_UNIT; break; case REALPART_EXPR:=