From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ED8BF3858C50; Sat, 14 Jan 2023 05:42:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED8BF3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673674942; bh=PoJ7z1GmKtFYjO7G3e6d8oTAvn7dILeekU0pehq67bs=; h=From:To:Subject:Date:From; b=BASmQjJ4QAMedyVnbDibFUAwMP91Q1CrAJI5UXfXbKVWRsrS94oU1ioYQ4jjKpy2L yEhLPqaTdN+pwxQOO2dlkSLz36G0gx0Dw8uevTeco6OtPEkDr0xRtnFNccVbm+5cXn 2MGt6nG9od3C0/ZDl8K7TZYuYfs1keMzH6dTVVBU= From: "pefoley2 at pefoley dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/108402] New: False positive Wuninitialized with ftrivial-auto-var-init=pattern Date: Sat, 14 Jan 2023 05:42:22 +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.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pefoley2 at pefoley dot com 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 attachments.created 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=3D108402 Bug ID: 108402 Summary: False positive Wuninitialized with ftrivial-auto-var-init=3Dpattern Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: pefoley2 at pefoley dot com Target Milestone: --- Created attachment 54271 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D54271&action=3Dedit Reduced test case This error showed up when compiling the upstream Linux kernel with ARCH=3Dum allyesconfig. It appears to be specific to the -ftrivial-auto-var-init=3Dpattern option. Reduced test case attached, extracted from https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/dri= vers/spi/spi-stm32-qspi.c#n519 e.g. gcc -v -O2 -ftrivial-auto-var-init=3Dpattern -Werror=3Duninitialized -c qsp= i.i -o /dev/null Using built-in specs. COLLECT_GCC=3Dgcc Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-12.2.1_p20221231/work/gcc-12-20221231/config= ure --host=3Dx86_64-pc-linux-gnu --build=3Dx86_64-pc-linux-gnu --prefix=3D/usr --bindir=3D/usr/x86_64-pc-linux-gnu/gcc-bin/12 --includedir=3D/usr/lib/gcc/x86_64-pc-linux-gnu/12/include --datadir=3D/usr/share/gcc-data/x86_64-pc-linux-gnu/12 --mandir=3D/usr/share/gcc-data/x86_64-pc-linux-gnu/12/man --infodir=3D/usr/share/gcc-data/x86_64-pc-linux-gnu/12/info --with-gxx-include-dir=3D/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12 --with-python-dir=3D/share/gcc-data/x86_64-pc-linux-gnu/12/python --enable-languages=3Dc,c++,d,go,fortran,ada --enable-obsolete --enable-secu= replt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --disable-libunwind-exceptions --enable-checking=3Drelease --with-bugurl=3Dhttps://bugs.gentoo.org/ --with-pkgversion=3D'Gentoo 12.2.1_p20221231 p8' --with-gcc-major-version-only --disable-esp --enable-libstdcxx-time --disable-libstdcxx-pch --enable-shared --enable-threads=3Dposix --enable-__cxa_atexit --enable-clocale=3Dgnu --enable-multilib --with-multilib-list=3Dm32,m64 --disable-fixed-point --enable-targets=3Dall --enable-libgomp --disable-libssp --disable-libada --disable-cet --disable-systemtap --disable-valgrind-annotations --enable-vtable-verify --with-zstd --enable-lto --with-isl --disable-isl-version-check --enable-default-pie --enable-default-ssp --with-build-config=3Dbootstrap-lto Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.2.1 20221231 (Gentoo 12.2.1_p20221231 p8) COLLECT_GCC_OPTIONS=3D'-v' '-O2' '-ftrivial-auto-var-init=3Dpattern' '-Werror=3Duninitialized' '-c' '-o' '/dev/null' '-mtune=3Dgeneric' '-march= =3Dx86-64' /usr/libexec/gcc/x86_64-pc-linux-gnu/12/cc1 -fpreprocessed qspi.i -quiet -dumpbase qspi.i -dumpbase-ext .i -mtune=3Dgeneric -march=3Dx86-64 -O2 -Werror=3Duninitialized -version -ftrivial-auto-var-init=3Dpattern -o /tmp/ccMHYckL.s GNU C17 (Gentoo 12.2.1_p20221231 p8) version 12.2.1 20221231 (x86_64-pc-linux-gnu) compiled by GNU C version 12.2.1 20221231, GMP version 6.2.1, MPFR version 4.2.0, MPC version 1.3.1, isl version isl-0.24-GMP GGC heuristics: --param ggc-min-expand=3D100 --param ggc-min-heapsize=3D131= 072 GNU C17 (Gentoo 12.2.1_p20221231 p8) version 12.2.1 20221231 (x86_64-pc-linux-gnu) compiled by GNU C version 12.2.1 20221231, GMP version 6.2.1, MPFR version 4.2.0, MPC version 1.3.1, isl version isl-0.24-GMP GGC heuristics: --param ggc-min-expand=3D100 --param ggc-min-heapsize=3D131= 072 Compiler executable checksum: 0fe3c6b2f620dfca480d344f2a96d9ed qspi.i: In function =E2=80=98stm32_qspi_dirmap_read=E2=80=99: qspi.i:40:20: error: =E2=80=98op=E2=80=99 is used uninitialized [-Werror=3D= uninitialized] 40 | struct spi_mem_op op; | ^~ qspi.i:40:20: note: =E2=80=98op=E2=80=99 declared here 40 | struct spi_mem_op op; | ^~ cc1: some warnings being treated as errors -fanalyzer additionally reports: qspi.i: In function =E2=80=98stm32_qspi_dirmap_read=E2=80=99: qspi.i:40:20: warning: use of uninitialized value =E2=80=98*(long int *)((c= har *)&op + offsetof(struct spi_mem_op, addr.nbytes))=E2=80=99 [CWE-457] [-Wanalyzer-use-of-uninitialized-value] 40 | struct spi_mem_op op; | ^~ =E2=80=98stm32_qspi_dirmap_read=E2=80=99: events 1-2 | | 40 | struct spi_mem_op op; | | ^~ | | | | | (1) region created on stack here | | (2) use of uninitialized value =E2=80=98*(l= ong int *)((char *)&op + offsetof(struct spi_mem_op, addr.nbytes))=E2=80=99 here | qspi.i:40:20: warning: use of uninitialized value =E2=80=98*(long int *)((c= har *)&op + offsetof(struct spi_mem_op, dummy.nbytes))=E2=80=99 [CWE-457] [-Wanalyzer-use-of-uninitialized-value] 40 | struct spi_mem_op op; | ^~ =E2=80=98stm32_qspi_dirmap_read=E2=80=99: events 1-2 | | 40 | struct spi_mem_op op; | | ^~ | | | | | (1) region created on stack here | | (2) use of uninitialized value =E2=80=98*(l= ong int *)((char *)&op + offsetof(struct spi_mem_op, dummy.nbytes))=E2=80=99 here | qspi.i:40:20: warning: use of uninitialized value =E2=80=98*(long int *)((c= har *)&op + offsetof(struct spi_mem_op, cmd.nbytes))=E2=80=99 [CWE-457] [-Wanalyzer-use-of-uninitialized-value] 40 | struct spi_mem_op op; | ^~ =E2=80=98stm32_qspi_dirmap_read=E2=80=99: events 1-2 | | 40 | struct spi_mem_op op; | | ^~ | | | | | (1) region created on stack here | | (2) use of uninitialized value =E2=80=98*(l= ong int *)((char *)&op + offsetof(struct spi_mem_op, cmd.nbytes))=E2=80=99 here |=