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

Christian Kreibich <christian at zeek dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |christian at zeek dot org

--- Comment #17 from Christian Kreibich <christian at zeek dot org> ---
The OP's original observation still holds with GCC 14.2.1 built as per the
below.

Since this is happening in Bison-generated code this is tricky to deal with:
one cannot instrument locally via pragmas to suppress, and since the
Bison-generated file includes the user's own parsing code one also doesn't want
to support the warning altogether in case it's correct elsewhere in the file.

---- test.c
#include <stdio.h>
#include <stdlib.h>

int
main(void)
{
    int yyssa[200];
    int *yyss = yyssa;

    if (yyss != yyssa)
        free(yyss);
    else
        printf("I beg to differ\n");

    return 0;
}
----

$ gcc -o test test.c
test.c: In function ‘main’:
test.c:11:9: warning: ‘free’ called on unallocated object ‘yyssa’
[-Wfree-nonheap-object]
   11 |         free(yyss);
      |         ^~~~~~~~~~
test.c:7:9: note: declared here
    7 |     int yyssa[200];
      |         ^~~~~

$ ./test
I beg to differ

$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/14/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --enable-libstdcxx-backtrace
--with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu
--enable-plugin --enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-14.2.1-build/gcc-14.2.1-20250110/obj-x86_64-redhat-linux/isl-install
--enable-offload-targets=nvptx-none,amdgcn-amdhsa --enable-offload-defaulted
--without-cuda-driver --enable-gnu-indirect-function --enable-cet
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
--with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.1 20250110 (Red Hat 14.2.1-7) (GCC)

Reply via email to