[Bug c++/79882] New: Lack of bounds checking on -ftemplate-depth argument

2017-03-05 Thread pefoley2 at pefoley dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79882

Bug ID: 79882
   Summary: Lack of bounds checking on -ftemplate-depth argument
   Product: gcc
   Version: 5.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: pefoley2 at pefoley dot com
  Target Milestone: ---

-ftemplate-depth appears to not check for overflow:

 gcc -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/5.4.0/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/5.4.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-5.4.0-r3/work/gcc-5.4.0/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/5.4.0
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/5.4.0
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/5.4.0/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/5.4.0/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/5.4.0/python
--enable-languages=c,c++,go,fortran --enable-obsolete --enable-secureplt
--disable-werror --with-system-zlib --enable-nls --without-included-gettext
--enable-checking=release --with-bugurl=https://bugs.gentoo.org/
--with-pkgversion='Gentoo 5.4.0-r3 p1.3, pie-0.6.5' --enable-libstdcxx-time
--enable-shared --enable-threads=posix --enable-__cxa_atexit
--enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64
--disable-altivec --disable-fixed-point --enable-targets=all --disable-libgcj
--enable-libgomp --disable-libmudflap --disable-libssp --enable-libcilkrts
--disable-libmpx --enable-vtable-verify --enable-libvtv --enable-lto --with-isl
--disable-isl-version-check --enable-libsanitizer
Thread model: posix
gcc version 5.4.0 (Gentoo 5.4.0-r3 p1.3, pie-0.6.5)


g++ -std=c++11 -ftemplate-depth=4294967296 a.cc
a.cc: In function ‘int main()’:
a.cc:12:26: fatal error: template instantiation depth exceeds maximum of 0 (use
-ftemplate-depth= to increase the maximum)

g++ -std=c++11 -ftemplate-depth=4294967297 a.cc
a.cc: In instantiation of ‘struct meme<2147483648u, int>’:
a.cc:12:26:   required from here
a.cc:3:20: fatal error: template instantiation depth exceeds maximum of 1 (use
-ftemplate-depth= to increase the maximum)

[Bug c/108402] New: False positive Wuninitialized with ftrivial-auto-var-init=pattern

2023-01-13 Thread pefoley2 at pefoley dot com via 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_m

[Bug tree-optimization/108402] False positive Wuninitialized with ftrivial-auto-var-init=pattern

2023-01-15 Thread pefoley2 at pefoley dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108402

pefoley2 at pefoley dot com changed:

   What|Removed |Added

  Attachment #54271|0   |1
is obsolete||

--- Comment #3 from pefoley2 at pefoley dot com ---
Created attachment 54275
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54275&action=edit
Partially reduced testcase

Testcase reduced via creduce/delta to the point that it fits in the attachment
size.

[Bug tree-optimization/108402] False positive Wuninitialized with ftrivial-auto-var-init=pattern

2023-01-15 Thread pefoley2 at pefoley dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108402

--- Comment #4 from pefoley2 at pefoley dot com ---
Yeah, I had a lot of trouble getting creduce to do something sane with the
testcase that didn't wind up just deleting everything.
I wound up trying delta, which got me a smaller, but still enormous repo.
It should also be reproducible via make O=um ARCH=um allyesconfig
drivers/spi/spi-stm32-qspi.o in a 6.1 linux kernel tree.

[Bug tree-optimization/108402] False positive Wuninitialized with ftrivial-auto-var-init=pattern

2023-01-16 Thread pefoley2 at pefoley dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108402

--- Comment #6 from pefoley2 at pefoley dot com ---
The attached file repos the issue for me.
I avoided trying to compress it per https://gcc.gnu.org/bugs/ "An attached
archive (tar, zip, shar, whatever) containing all (or some) of the above."
being listed under "What we do not want".

And yeah, the steps to repo from a kernel checkout were added mostly for
completeness, I didn't expect people to need to use them.

[Bug middle-end/80922] #pragma diagnostic ignored not honoured with -flto

2023-01-20 Thread pefoley2 at pefoley dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80922

pefoley2 at pefoley dot com changed:

   What|Removed |Added

 CC||pefoley2 at pefoley dot com

--- Comment #8 from pefoley2 at pefoley dot com ---
Note that this appears to be affecting the gcc source tree.

Attempting a build with --with-build-config=bootstrap-lto --enable-werror
errors out with:
In function ‘release’,
inlined from ‘release’ at ../../gcc/vec.h:1915:0,
inlined from ‘__dt_base ’ at ../../gcc/vec.h:1574:0,
inlined from ‘visit_reference_op_call.isra’ at
../../gcc/tree-ssa-sccvn.cc:5562:0:
../../gcc/vec.h:316: error: ‘free’ called on unallocated object ‘accesses’
[-Werror=free-nonheap-object]
  316 |   ::free (v);
  |
../../gcc/tree-ssa-sccvn.cc: In function ‘visit_reference_op_call.isra’:
../../gcc/tree-ssa-sccvn.cc:5457: note: declared here
 5457 |   auto_vec accesses;
  |
lto1: all warnings being treated as errors

Due to this pragma being ignored:
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/vec.h;h=a536b68732ddcb9ed7b223803308b3e079a53969;hb=HEAD#l300

[Bug middle-end/80922] #pragma diagnostic ignored not honoured with -flto

2023-01-22 Thread pefoley2 at pefoley dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80922

--- Comment #10 from pefoley2 at pefoley dot com ---
It does? I wasn't aware of that.
My read of the configure options is that the two options are tangential.
And from a quick skim, I couldn't find anything that made enabling lto suppress
Werror.
Besides, regardless of whether it's supported or not, it's another example of
this issue in the wild.