From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8DD433858CDA; Tue, 17 Sep 2024 08:36:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8DD433858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1726562188; bh=HNNM+op5fwJyBjm676mlsf606NsuUJDi4SO0hGT3fgg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CLJGxEEZJzhlpbOwSJU1c63bM8B35+sGlP4XwHnCcE7oovD3ZgCLlbyg8gdTB6fLs qrBS4q1i7vX2VotQ1pCovDnogUPIk2WvpMi0ApyKxZ+Suxg99AQVRJmsTOLas3Ysip yXN1dqSaI+FIb0w9pZmrircVcjifTIpYXEnMav9I= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/116357] [12/13/14/15 Regression] The item's address of the array is not correct if aligned is used Date: Tue, 17 Sep 2024 08:36:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: component cf_reconfirmed_on cc bug_status everconfirmed 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=3D116357 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Component|tree-optimization |c Last reconfirmed| |2024-09-17 CC| |jsm28 at gcc dot gnu.org, | |rguenth at gcc dot gnu.org Status|UNCONFIRMED |NEW Ever confirmed|0 |1 --- Comment #5 from Richard Biener --- The optimization issue is because we have an element type that looks like constant 32> unit-size constant 4> user align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff69b2738 precision:32 min max pointer_to_this > in particular with TYPE_ALIGN > TYPE_SIZE which is a "cannot happen". Beca= use ARRAY_REF records the element size in units of element alignment this ends up as zero ... In this case value-numbering makes ARRAY_REF OP2 explicit while keeping it implicit ends up being "fine" (fine as in still densely packing spinlock_t and thus giving elements wrong alignment). I wonder whether the bug is that sizeof (spinlock_t) is 4, but of course that might be difficult to change. But I suppose this is also how C works; possibly the C frontend should build a variant type of the element type if over-alignment should be ignored - putting in the over-aligned type most definitely breaks the middle-end with regard to how ARRAY_REF is defined. This is a C frontend issue, it produces wrong GENERIC.=