From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AE5383858C54; Tue, 27 Dec 2022 22:19:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE5383858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672179554; bh=0CmIdD0ggUaw718W2JkRNUst5CC6+d5HMm0ncL4VPcI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wQvXsRaKekLuCPdhlB/tbrcZQCzBSLRaidg/FI5Ovjze45Eb/BOweltfgOiRgEwj7 JMLldeRqeO7KHJ2O+fHylxvlJ9ncinZQ1Wo5BSX1WjQKt+MJyggDyDpEOLVgvOG8kz VHyoWJCVNJnBUUTPWHuzYhgTrEz3x/yU2gN35Xyk= From: "gabravier at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/107115] Wrong codegen from TBAA under stores that change effective type? Date: Tue, 27 Dec 2022 22:19:12 +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: 13.0 X-Bugzilla-Keywords: alias, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: gabravier at gmail dot com 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: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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=3D107115 Gabriel Ravier changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |gabravier at gmail dot com --- Comment #13 from Gabriel Ravier --- Idk if it qualifies as the same bug or if this will prove to bee particular= ly useful, but just to make sure the corresponding issue in C++, triggered by = this slightly altered code (so that it hopefully respects the stricter rules C++= has w.r.t. implicit object creation) which also fails to execute correctly on G= CC, is fixed by the fix to this issue, I'll post here the corresponding code: #include #include #include void test1(long *p1) { p1 =3D (long *)new ((char*)p1) char[sizeof(long)]; p1[0] =3D 1; } long test2(long long *p2, int index1, int index2) { p2 =3D (long long *)new ((char*)p2) char[sizeof(long long)]; p2[index1] =3D 2; return p2[index2]; } long test3(long *p3, int index2, long value) { p3 =3D (long *)new ((char*)p3) char[sizeof(long)]; p3[index2] =3D 3; p3[index2] =3D value; return p3[0]; } long test4(void *p4, int index1, int index2) { test1((long *)p4); long temp =3D test2((long long *)p4, index1, index2); return test3((long *)p4, index2, temp); } long (*volatile vtest)(void *, int, int) =3D test4; int main(void) { void *pp =3D malloc(sizeof(long long)); if (!pp) abort(); long result =3D vtest(pp, 0, 0); printf("%lu/%lu\n", *std::launder((long *)pp), result); }=