From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id 49D4B3858C62 for ; Wed, 8 Mar 2023 13:08:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 49D4B3858C62 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x22f.google.com with SMTP id h9so16514357ljq.2 for ; Wed, 08 Mar 2023 05:08:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678280910; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1zkyJUhKjapNA7d2V/5jTIIHbewOXxHQ3Jt7drvF2CM=; b=ciydY5oEDc09CAK/tHS36omvtAkSb3h9Y5zu3ohHe8hTKErGewt7SLPo7E9UcL4aJu /I0uTXrjQ7MA9T/eIUJMHdml5yktcw7gu1XyWQ9j8XIjCXmTDEovvbc+xTcHDCksIAbv DK1jDfc+pt4HgAmQFr6gd/RPvXd8PJ0IuapWPMx5Pj16Df1Zbg8NNvRCqxri7quRfIZZ CBKQMdER/PTwQa6N3iGA9nFkSjqRjBj3PKhPMJCgHdiBbyJ0Q1HWKiJLsBLie4vCA418 DU90Okm7E58K8YfmWKjRf+OodZTXGFvYZPET+Cg85AECJKBJkGCsyrroQT3mulwUcV5j XOFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678280910; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1zkyJUhKjapNA7d2V/5jTIIHbewOXxHQ3Jt7drvF2CM=; b=3R6PnvPIU0N9sb/AAyrZ805NOAIZUS99Dwp3IkUERj6Xo77UVEMy4AVEgM0OR0tIKM 9rlgjP0V5XZbESz4Pchi1NXBvbsg3VmmflzwtpaEvGoj+tk3dcHSfeEWM13NOAfDs3vG GYtjNdxm7tvc3YcKDkkl6Se6nk74Zcgdq0lrxCaplKlKqQJfi8w73ciZ3wcAXkHe4ydh AN0lgwbw7YQDAifr8k/KK+P6TKttJsQ2RdK7/nsJZKpvNjAz4vYFIMYtYz4orZ+lqbE9 RSqf7j3rzOlNpFUFNpBmomspVHm6gPvTfY6SIUaCBN8ioUitPqqKOlxJb5CuLALKH9gk r6Ow== X-Gm-Message-State: AO0yUKVDsaqn1NwXjEANS5h2LRb1G7fwMmM1A6A2ncvjOHtERpqeS62o jhYhClVtNeBSgRiWkMT9of4+3xk+W5MhVGAbb6M= X-Google-Smtp-Source: AK7set99LApJcGiVd0FFrC8fpNwR3v15aRbrBd/H9JNJlcVEJm57tPbQlxxo8s8ljOvL8oATrYsREOSuM6qcnRSvLOI= X-Received: by 2002:a2e:a36a:0:b0:295:9040:fb0b with SMTP id i10-20020a2ea36a000000b002959040fb0bmr5595995ljn.10.1678280909645; Wed, 08 Mar 2023 05:08:29 -0800 (PST) MIME-Version: 1.0 References: <4c2566de-0352-22f7-3d86-44a2aa1f9957@suse.cz> In-Reply-To: <4c2566de-0352-22f7-3d86-44a2aa1f9957@suse.cz> From: Richard Biener Date: Wed, 8 Mar 2023 14:08:16 +0100 Message-ID: Subject: Re: [PATCH] -Wdangling-pointer: don't mark SSA lhs sets as stores To: =?UTF-8?Q?Martin_Li=C5=A1ka?= Cc: Alexandre Oliva , gcc-patches@gcc.gnu.org, msebor@redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Mar 8, 2023 at 2:04=E2=80=AFPM Martin Li=C5=A1ka w= rote: > > On 3/3/23 12:12, Richard Biener via Gcc-patches wrote: > > On Fri, Mar 3, 2023 at 9:30=E2=80=AFAM Alexandre Oliva wrote: > >> > >> On Feb 17, 2023, Richard Biener wrote: > >> > >>>> * gimple-ssa-warn-access.cc > >>>> (pass_waccess::check_dangling_stores): Skip non-stores. > >>>> > >>>> for gcc/testsuite/ChangeLog > >>>> > >>>> * g++.dg/warn/Wdangling-pointer.C (warn_init_ref_member): Add > >>>> two new variants, one fixed, one xfailed. > >>>> * c-c++-common/Wdangling-pointer-5.c > >>>> (nowarn_store_arg_store_arg): Add now-expected warnings. > >> > >> Ping? > >> https://gcc.gnu.org/pipermail/gcc-patches/2023-February/612186.html > > > > I was hoping Martin would chime in, but he didn't. > > > > So - OK. > > > > Thanks, > > Richard. > > > >> > >> -- > >> Alexandre Oliva, happy hacker https://FSFLA.org/blogs/l= xo/ > >> Free Software Activist GNU Toolchain Engineer > >> Disinformation flourishes because many people care deeply about injust= ice > >> but very few check the facts. Ask me about > > Hi. > > I've just noticed this change triggered one more warning for qemu 7.1.0: > > cc -m64 -mcx16 -Ilibqemuutil.a.p -I. -I.. -Isubprojects/libvhost-user -I.= ./subprojects/libvhost-user -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/= glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/inclu= de/blkid -I/usr/include/gio-unix-2.0 -I/usr/include/p11-kit-1 -I/usr/includ= e/pixman-1 -fdiagnostics-color=3Dauto -Wall -Winvalid-pch -Werror -std=3Dgn= u11 -O2 -isystem /home/abuild/rpmbuild/BUILD/qemu-7.1.0/linux-headers -isys= tem linux-headers -iquote . -iquote /home/abuild/rpmbuild/BUILD/qemu-7.1.0 = -iquote /home/abuild/rpmbuild/BUILD/qemu-7.1.0/include -iquote /home/abuild= /rpmbuild/BUILD/qemu-7.1.0/tcg/i386 -pthread -D_GNU_SOURCE -D_FILE_OFFSET_B= ITS=3D64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef = -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwra= pv -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-se= curity -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-= externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=3D2 -W= no-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -fstack-protec= tor-strong -O2 -Wall -fstack-protector-strong -funwind-tables -fasynchronou= s-unwind-tables -fstack-clash-protection -Werror=3Dreturn-type -U_FORTIFY_S= OURCE -D_FORTIFY_SOURCE=3D2 -fPIE -MD -MQ libqemuutil.a.p/util_async.c.o -M= F libqemuutil.a.p/util_async.c.o.d -o libqemuutil.a.p/util_async.c.o -c ../= util/async.c > In file included from /home/abuild/rpmbuild/BUILD/qemu-7.1.0/include/qemu= /coroutine.h:18, > from /home/abuild/rpmbuild/BUILD/qemu-7.1.0/include/bloc= k/aio.h:20, > from ../util/async.c:28: > ../util/async.c: In function 'aio_bh_poll': > /home/abuild/rpmbuild/BUILD/qemu-7.1.0/include/qemu/queue.h:303:22: error= : storing the address of local variable 'slice' in '*ctx.bh_slice_list.sqh_= last' [-Werror=3Ddangling-pointer=3D] > 303 | (head)->sqh_last =3D &(elm)->field.sqe_next; = \ > | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ > ../util/async.c:161:5: note: in expansion of macro 'QSIMPLEQ_INSERT_TAIL' > 161 | QSIMPLEQ_INSERT_TAIL(&ctx->bh_slice_list, &slice, next); > | ^~~~~~~~~~~~~~~~~~~~ > ../util/async.c:156:17: note: 'slice' declared here > 156 | BHListSlice slice; > | ^~~~~ > ../util/async.c:156:17: note: 'ctx' declared here > > which I reduced to: > > $ cat util_async.i > typedef struct BHListSlice BHListSlice; > struct BHListSlice { > struct { > BHListSlice *sqe_next; > } next; > } *aio_bh_poll_s; > struct AioContext { > struct { > BHListSlice *sqh_first; > BHListSlice **sqh_last; > } bh_slice_list; > } aio_bh_dequeue(); > int aio_bh_poll_bh; > int aio_bh_poll(struct AioContext *ctx) { > BHListSlice slice; > (&ctx->bh_slice_list)->sqh_last =3D &(slice.next.sqe_next); > while (aio_bh_poll_s) { > unsigned flags; > aio_bh_dequeue(&flags); > if (aio_bh_poll_bh) { > (&ctx->bh_slice_list)->sqh_last =3D &(&ctx->bh_slice_list)->sqh_fir= st; > continue; > } > } > return 0; > } > > $ gcc util_async.i -c -Werror=3Ddangling-pointer > util_async.i: In function =E2=80=98aio_bh_poll=E2=80=99: > util_async.i:16:35: error: storing the address of local variable =E2=80= =98slice=E2=80=99 in =E2=80=98*ctx.bh_slice_list.sqh_last=E2=80=99 [-Werror= =3Ddangling-pointer=3D] > 16 | (&ctx->bh_slice_list)->sqh_last =3D &(slice.next.sqe_next); > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ > util_async.i:15:15: note: =E2=80=98slice=E2=80=99 declared here > 15 | BHListSlice slice; > | ^~~~~ > util_async.i:15:15: note: =E2=80=98ctx=E2=80=99 declared here > cc1: some warnings being treated as errors > > Is the emitted warning correct? For the reduced testcase yes, if !aio_bh_poll_s (or !aio_bh_poll_bh) the stored pointer remains local. But I can imagine this to be known (to the programmer) to not happen for the original code and eventually GCC jump-threading some never reachable path (we've been there before). Richard. > Thank you, > Martin