public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106868] New: Bogus -Wdangling-pointer warning with -O1
@ 2022-09-07  8:47 medhefgo at web dot de
  2022-09-07  9:05 ` [Bug tree-optimization/106868] [12/13 Regression] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: medhefgo at web dot de @ 2022-09-07  8:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106868

            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 = q;
  }
  char *a = __builtin_memcpy(*p, "", 1);
  *a = 0;
}

$ gcc -c -o/dev/null testcase.c -Wdangling-pointer -O1
testcase.c: In function ‘false_dangling’:
testcase.c:9:6: warning: using dangling pointer ‘a’ to ‘q’
[-Wdangling-pointer=]
    9 |   *a = 0;
      |   ~~~^~~
testcase.c:4:11: note: ‘q’ declared here
    4 |     void *q;
      |

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/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=c,c++,ada,fortran,go,lto,objc,obj-c++,d --enable-bootstrap
--prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--with-build-config=bootstrap-lto --with-linker-hash-style=gnu
--with-system-zlib --enable-__cxa_atexit --enable-cet=auto
--enable-checking=release --enable-clocale=gnu --enable-default-pie
--enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object
--enable-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (GCC)

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-12-12 11:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-07  8:47 [Bug c/106868] New: Bogus -Wdangling-pointer warning with -O1 medhefgo at web dot de
2022-09-07  9:05 ` [Bug tree-optimization/106868] [12/13 Regression] " rguenth at gcc dot gnu.org
2022-09-12 16:18 ` msebor at gcc dot gnu.org
2022-09-12 17:04 ` msebor at gcc dot gnu.org
2022-12-05  9:41 ` rguenth at gcc dot gnu.org
2022-12-05 13:56 ` cvs-commit at gcc dot gnu.org
2022-12-05 14:06 ` rguenth at gcc dot gnu.org
2022-12-12 11:20 ` [Bug tree-optimization/106868] [12 " cvs-commit at gcc dot gnu.org
2022-12-12 11:20 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).