From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6D80C385840A; Wed, 7 Sep 2022 08:47:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D80C385840A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662540424; bh=0sdjBgw+W0nUusnUOa6V9Az+z4DfeA7MmVfw0q3NIck=; h=From:To:Subject:Date:From; b=PSpL9PbPYQ/Sr+7nPQXwogaZjT6+bjpaKC0xyddGGXfEMwPg6mXg4evfZktZLzqzT +6jcwZpLF+2k/FVipot5A2G/ETJM29PeGGRB6ujhP9IFafPSgfsoCYU1SmyCyPiLvA 3Z1NiThw2rbQkolp94LjJ9ol85I1F9QiIeDm2Ssg= From: "medhefgo at web dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/106868] New: Bogus -Wdangling-pointer warning with -O1 Date: Wed, 07 Sep 2022 08:47:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: medhefgo at web dot de X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D106868 Bug ID: 106868 Summary: Bogus -Wdangling-pointer warning with -O1 Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: medhefgo at web dot de Target Milestone: --- The following code gives me a (afaik) bogus dangling pointer warning: # cat testcase.c void alloc(void **p); void false_dangling(char **p) { { void *q; alloc(&q); *p =3D q; } char *a =3D __builtin_memcpy(*p, "", 1); *a =3D 0; } $ gcc -c -o/dev/null testcase.c -Wdangling-pointer -O1 testcase.c: In function =E2=80=98false_dangling=E2=80=99: testcase.c:9:6: warning: using dangling pointer =E2=80=98a=E2=80=99 to =E2= =80=98q=E2=80=99 [-Wdangling-pointer=3D] 9 | *a =3D 0; | ~~~^~~ testcase.c:4:11: note: =E2=80=98q=E2=80=99 declared here 4 | void *q; | $ gcc -v Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/gcc/src/gcc/configure --enable-languages=3Dc,c++,ada,fortran,go,lto,objc,obj-c++,d --enable-boots= trap --prefix=3D/usr --libdir=3D/usr/lib --libexecdir=3D/usr/lib --mandir=3D/usr= /share/man --infodir=3D/usr/share/info --with-bugurl=3Dhttps://bugs.archlinux.org/ --with-build-config=3Dbootstrap-lto --with-linker-hash-style=3Dgnu --with-system-zlib --enable-__cxa_atexit --enable-cet=3Dauto --enable-checking=3Drelease --enable-clocale=3Dgnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-obj= ect --enable-libstdcxx-backtrace --enable-link-serialization=3D1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=3Dposix --disable-libssp --disable-libstdc= xx-pch --disable-werror Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.2.0 (GCC)=