From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C7781385828E; Tue, 30 Apr 2024 11:05:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7781385828E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714475121; bh=4dKcRjby3sfRW8w4onhyf37WdIz9+FkyeQbrYXJ7lG8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mn0TvDhxaHkWKTpC2+T70ikzqVqQ3aysD6z35RabaCbvVOS0Oyg/ZlXgojqIl+VaZ RkkDNYw6+uMqgcS/lZVkPSP9VzdDDOkazCIANQdZJ3pymhwHU6F07TCpTcSKuVebI4 4Ms2AtSMLMQHlUEw7hmzQ/vuoNhbCFH0UDYVgpvQ= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: =?UTF-8?B?W0J1ZyBtaWRkbGUtZW5kLzEzNDIxXSBJQTMyIGJpZ21lbSBwb2lu?= =?UTF-8?B?dGVyIHN1YnRyYWN0aW9uIGFuZCDigJNmdHJhcHYgb3B0aW9uIGNhdXNlcyB1?= =?UTF-8?B?bmp1c3RpZmllZCBwcm9ncmFtIGFib3J0?= Date: Tue, 30 Apr 2024 11:05:18 +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: 3.3.2 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 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=3D13421 --- Comment #17 from GCC Commits --- The master branch has been updated by Richard Biener : https://gcc.gnu.org/g:667c19de86b33648f5f4599f589a5e02adbb35cb commit r15-67-g667c19de86b33648f5f4599f589a5e02adbb35cb Author: Richard Biener Date: Tue Apr 16 14:05:35 2024 +0200 middle-end/13421 - -ftrapv vs. POINTER_DIFF_EXPR Currently we expand POINTER_DIFF_EXPR using subv_optab when -ftrapv (but -fsanitize=3Dundefined does nothing). That's not consistent with the behavior of POINTER_PLUS_EXPR which never uses addv_optab with -ftrapv. Both are because of the way we select whether to use the trapping or the non-trapping optab - we look at the result type of the expression and check trapv =3D INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_TRAPS (type); the bugreport correctly complains that -ftrapv affects pointer subtraction (there's no -ftrapv-pointer). Now that we have POINTER_DIFF_EXPR we can honor that appropriately. The patch moves both POINTER_DIFF_EXPR and POINTER_PLUS_EXPR handling so they will never consider trapping (or saturating) optabs. PR middle-end/13421 * optabs-tree.cc (optab_for_tree_code): Do not consider {add,sub}v or {us,ss}{add,sub} optabs for POINTER_DIFF_EXPR or POINTER_PLUS_EXPR.=