public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/108402] New: False positive Wuninitialized with ftrivial-auto-var-init=pattern
@ 2023-01-14  5:42 pefoley2 at pefoley dot com
  2023-01-14  5:49 ` [Bug tree-optimization/108402] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: pefoley2 at pefoley dot com @ 2023-01-14  5:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108402
           Summary: False positive Wuninitialized with
                    ftrivial-auto-var-init=pattern
           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=54271&action=edit
Reduced test case

This error showed up when compiling the upstream Linux kernel with ARCH=um
allyesconfig.
It appears to be specific to the -ftrivial-auto-var-init=pattern option.

Reduced test case attached, extracted from
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/spi/spi-stm32-qspi.c#n519

e.g.
gcc -v -O2 -ftrivial-auto-var-init=pattern -Werror=uninitialized -c qspi.i -o
/dev/null
Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-12.2.1_p20221231/work/gcc-12-20221231/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/12
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/12/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/12
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/12/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/12/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/12/python
--enable-languages=c,c++,d,go,fortran,ada --enable-obsolete --enable-secureplt
--disable-werror --with-system-zlib --enable-nls --without-included-gettext
--disable-libunwind-exceptions --enable-checking=release
--with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo
12.2.1_p20221231 p8' --with-gcc-major-version-only --disable-esp
--enable-libstdcxx-time --disable-libstdcxx-pch --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
--enable-multilib --with-multilib-list=m32,m64 --disable-fixed-point
--enable-targets=all --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=bootstrap-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='-v' '-O2' '-ftrivial-auto-var-init=pattern'
'-Werror=uninitialized' '-c' '-o' '/dev/null' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-pc-linux-gnu/12/cc1 -fpreprocessed qspi.i -quiet
-dumpbase qspi.i -dumpbase-ext .i -mtune=generic -march=x86-64 -O2
-Werror=uninitialized -version -ftrivial-auto-var-init=pattern -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=100 --param ggc-min-heapsize=131072
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=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 0fe3c6b2f620dfca480d344f2a96d9ed
qspi.i: In function ‘stm32_qspi_dirmap_read’:
qspi.i:40:20: error: ‘op’ is used uninitialized [-Werror=uninitialized]
   40 |  struct spi_mem_op op;
      |                    ^~
qspi.i:40:20: note: ‘op’ declared here
   40 |  struct spi_mem_op op;
      |                    ^~
cc1: some warnings being treated as errors


-fanalyzer additionally reports:
qspi.i: In function ‘stm32_qspi_dirmap_read’:
qspi.i:40:20: warning: use of uninitialized value ‘*(long int *)((char *)&op +
offsetof(struct spi_mem_op, addr.nbytes))’ [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
   40 |  struct spi_mem_op op;
      |                    ^~
  ‘stm32_qspi_dirmap_read’: events 1-2
    |
    |   40 |  struct spi_mem_op op;
    |      |                    ^~
    |      |                    |
    |      |                    (1) region created on stack here
    |      |                    (2) use of uninitialized value ‘*(long int
*)((char *)&op + offsetof(struct spi_mem_op, addr.nbytes))’ here
    |
qspi.i:40:20: warning: use of uninitialized value ‘*(long int *)((char *)&op +
offsetof(struct spi_mem_op, dummy.nbytes))’ [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
   40 |  struct spi_mem_op op;
      |                    ^~
  ‘stm32_qspi_dirmap_read’: events 1-2
    |
    |   40 |  struct spi_mem_op op;
    |      |                    ^~
    |      |                    |
    |      |                    (1) region created on stack here
    |      |                    (2) use of uninitialized value ‘*(long int
*)((char *)&op + offsetof(struct spi_mem_op, dummy.nbytes))’ here
    |
qspi.i:40:20: warning: use of uninitialized value ‘*(long int *)((char *)&op +
offsetof(struct spi_mem_op, cmd.nbytes))’ [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
   40 |  struct spi_mem_op op;
      |                    ^~
  ‘stm32_qspi_dirmap_read’: events 1-2
    |
    |   40 |  struct spi_mem_op op;
    |      |                    ^~
    |      |                    |
    |      |                    (1) region created on stack here
    |      |                    (2) use of uninitialized value ‘*(long int
*)((char *)&op + offsetof(struct spi_mem_op, cmd.nbytes))’ here
    |

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

end of thread, other threads:[~2023-07-19 16:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-14  5:42 [Bug c/108402] New: False positive Wuninitialized with ftrivial-auto-var-init=pattern pefoley2 at pefoley dot com
2023-01-14  5:49 ` [Bug tree-optimization/108402] " pinskia at gcc dot gnu.org
2023-01-14  6:56 ` pinskia at gcc dot gnu.org
2023-01-15 18:46 ` pefoley2 at pefoley dot com
2023-01-15 18:51 ` pefoley2 at pefoley dot com
2023-01-15 19:23 ` pinskia at gcc dot gnu.org
2023-01-16 22:47 ` pefoley2 at pefoley dot com
2023-07-19 16:03 ` arnd at linaro dot 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).