From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BEBC03858D20; Tue, 9 Apr 2024 18:42:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BEBC03858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712688125; bh=YPQQjVaqfPl+PHJTr6EdYTFzHLGDD6BuVmPDezzZwMk=; h=From:To:Subject:Date:From; b=JwB+ZSdJl1kYQkIMR6S4Fj/EsTg9am+GMdeqCNbVLsgXRUEoFXuUoJSnOZOgLbGLt uHcym02yvMda8FzVlsMmY+WxOx0l/4leG21gN3xaW5BGBiKvGHawHpDN3FKhTcKxM9 +gobeXmANarcT2sp1+mFSBu4OTQasvT8+V/GqFLY= From: "iains at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114663] New: Several contracts test cases fail with -fsanitize=undefined -fsanitize-trap Date: Tue, 09 Apr 2024 18:42:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: testsuite-fail, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: iains 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: bug_id short_desc product version bug_status keywords 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=3D114663 Bug ID: 114663 Summary: Several contracts test cases fail with -fsanitize=3Dundefined -fsanitize-trap Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: testsuite-fail, wrong-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: iains at gcc dot gnu.org CC: jason at gcc dot gnu.org Target Milestone: --- I found this while working on -funreachable-traps (but the failure equally occurs with -fsanitize=3Dundefined -fsanitize-trap) FAIL: g++.dg/contracts/contracts10.C execution test FAIL: g++.dg/contracts/contracts18.C execution test FAIL: g++.dg/contracts/contracts19.C execution test FAIL: g++.dg/contracts/contracts2.C execution test Initial analysis is that somehow the lowering of the contracts code is exploiting UB [which has a large measure of irony if true] to make these ca= ses pass, for example contracts2.C optimised tree dump contains: ;; Function main (main, funcdef_no=3D0, decl_uid=3D2531, cgraph_uid=3D1, symbol_order=3D0) int main () { int x; int D.2551; const struct D.2542; int _2; : x_1 =3D 1; if (x_1 < 0) goto ; [INV] else goto ; [INV] : __builtin_unreachable (); : if (x_1 <=3D 0) goto ; [INV] else goto ; [INV] : =3D=3D=3D=3D=3D When (default) the __builtin_unreachable () is replaced with nothing (i.e. = it falls though) the test case passes. When we replace the __builtin_unreachable () with a trap (either using the ubsan or -funreachable-traps style) the test case fails with the trap. This seems to be unlikely to be what was intended (or if it was intended it= 's terribly fragile); I'm labelling it wrong code for now. Similar code patterns exist in the other cases mentioned.=