From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3BB8B3858C78; Wed, 15 Mar 2023 21:51:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3BB8B3858C78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678917068; bh=Cgd+v/jg+fXPRHGfRp7NXByQUDSREFVGiZpzvblvKDs=; h=From:To:Subject:Date:From; b=uz2gMDODHdGoWfBWweYcTUk1J58GFr0+Dx8osmKbZf2yLCOuC7qxZB7zLBqZmKAMR r+fYO42gjvjr1dIgVpERPqqORy5SuXFPOvn9tCNOXbg5kaSGwNP/TX3WCv3TQx6y+Y Ah45ot8tf4RjFJsNooD/JdNm3V8o6/ZXKrP5Vpss= From: "shaohua.li at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/109151] New: UBsan misses a divide-by-zero Date: Wed, 15 Mar 2023 21:51:07 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: shaohua.li at inf dot ethz.ch 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: 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=3D109151 Bug ID: 109151 Summary: UBsan misses a divide-by-zero Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: shaohua.li at inf dot ethz.ch CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxi= n at gcc dot gnu.org Target Milestone: --- For the following code, UBsan failed to report the divide-by-zero, while Clang's UBsan could. Compiler explorer: https://godbolt.org/z/Y73vrf8zK %cat a.c int a, c; short b; long d; int main() {=20 a =3D (short)(d =3D=3D c | b > 9) / 0;=20 return a; } % % gcc -fsanitize=3Dundefined a.c &&./a.out Floating point exception % % clang -fsanitize=3Dundefined a.c &&./a.out /a.c:5:42: runtime error: division by zero %=