From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 401813858C54; Wed, 1 Mar 2023 14:38:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 401813858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677681491; bh=mtQamTiA2j2WeVUaKqNvHsnwLMAMWbKeAzBp6Tbk7Y8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=j+GdDsEepHnGY2bJ9q8Epm+SEi+bRlt4EPfcC/6B6gZlvaMTMAS6te0kFB4yCiRcC Ol3EptvBqFiVGXifqLT/WI3ph/RRAIaLtW8/JfWqiXlxtDsxYCHow9AO5b946lBySa xGB/xADzVW7b4Bu6iNWGg94V+2bNq/Jc3M9F1dgg= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107561] [13 Regression] g++.dg/pr71488.C and [g++.dg/warn/Warray-bounds-16.C -m32] regression due to -Wstringop-overflow problem Date: Wed, 01 Mar 2023 14:38:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: diagnostic, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 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=3D107561 --- Comment #17 from Richard Biener --- (In reply to Jakub Jelinek from comment #16) > (In reply to Richard Biener from comment #15) > > The compiler doesn't know that the allocation function cannot clobber *= this. > > The C++ frontend tries to communicate this by making 'this' restrict > > qualified > > and we make use of that info, but for calls we do not know how to use t= he > > info. > >=20 > > Maybe we can special-case directly the actual parameter case and compute > > the restrictness info for the call arguments. The canonical example is > >=20 > > void bar (void); > > struct X { > > X (int); > > int i; > > int j; > > }; > >=20 > > X::X(int k) > > { > > i =3D k; > > bar (); > > j =3D i !=3D k; > > } > >=20 > > where if I understand you correctly, bar () is not allowed to modify *t= his > > (unless I pass it an argument to it, of course), even if *this is for > > example >=20 > Why? Because it is a constructor and the object isn't fully constructed = yet > at that point? For normal methods I certainly don't see anything that wo= uld > preclude such modifications. The canonical C example would be void bar (void); void foo (struct X * restrict this, int k) { this->i =3D k; bar (); this->j =3D i !=3D k; } where as I understand bar () cannot modify what *this points to since it cannot build a proper derived access from 'this' (unless I pass it to bar). The C++ frontend annotates 'this' with restrict. For my example I get void X::X (struct X * const this, int k) { # PT =3D { D.2806 } (nonlocal, restrict) struct X * const this_5(D) =3D this; int k_7(D) =3D k; int _1; bool _2; int _3; : MEM[(struct X *)this_5(D) clique 1 base 1] =3D{v} {CLOBBER}; MEM[(struct X *)this_5(D) clique 1 base 1].i =3D k_7(D); # USE =3D nonlocal escaped # CLB =3D nonlocal escaped bar (); _1 =3D MEM[(struct X *)this_5(D) clique 1 base 1].i; _2 =3D _1 !=3D k_7(D); # RANGE [irange] int [0, 1] NONZERO 0x1 _3 =3D (int) _2; MEM[(struct X *)this_5(D) clique 1 base 1].j =3D _3; return; }=