From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2CA56384AB5F; Mon, 22 Apr 2024 20:04:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CA56384AB5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713816286; bh=dgPJRGAfMT7TS9y8EYx5nDTDAL91GSquuE3epsMLwg8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=FAumDOZ78VjFlKT0OSet6CsBW/ESrLet/Nlzc8NK5K1y5RaXfCbFS/5fJrN8S0num HQJ38ZrAm5xPC3+GNFe4HjDC6znyYf4FAH/eWanrHJ1mxeHPJ8JW9EoxvTcbV/pCnC sXFS8tQKKIoA3CtSXd1iXpwibV6koMkg41+Axk6c= From: "qinzhao at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109071] -Warray-bounds false positive warnings due to code duplication from jump threading Date: Mon, 22 Apr 2024 20:04:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: qinzhao at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: qinzhao 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=3D109071 --- Comment #7 from qinzhao at gcc dot gnu.org --- (In reply to Kees Cook from comment #6) > (In reply to qinzhao from comment #5) > > adding __attribute__ ((noreturn)) to the routine "warn" can eliminate t= he > > false positive warning. >=20 > But it does return... it's not an assert. ***the original code is: if (index >=3D 4) warn (); *regs =3D sg->vals[index]; if the routine "warn" does return, then it's reasonable to convert the above original code to: ***the transformed code: if (index >=3D 4) { warn (); *regs =3D sg->vals[index]; /* here, index >=3D 4, therefore, out-of-b= ound */ } else *regs =3D sg->vals[index];=