[Bug other/96447] New: False positive -Wstringop-overflow with -O3
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96447 Bug ID: 96447 Summary: False positive -Wstringop-overflow with -O3 Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: daniel at constexpr dot org Target Milestone: --- Created attachment 48990 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48990&action=edit test.c The attached reduced test case results in the following false positive warning at -03 (but not -O2) without any additional compiler flags with both GCC 10.2.0 and GCC 11.0.0 (compiled from git today): test.c: In function ‘load’: test.c:23:25: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 23 | data[i] = get8u(s); | ^~ test.c:21:23: note: at offset 4 to object ‘data’ with size 4 declared here 21 | unsigned char data[4]; | ^~~~
[Bug tree-optimization/96447] False positive -Wstringop-overflow with -O3 due to loop unrolling
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96447 --- Comment #2 from Daniel Scharrer --- For warnings enabled by something like -fanalyzer this might be reasonable but for a warning I enabled by default (not even requiring -Wall) the bar should ideally be a bit higher.
[Bug other/56273] New: [4.8 regression] Bogus -Warray-bounds warning
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273 Bug #: 56273 Summary: [4.8 regression] Bogus -Warray-bounds warning Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: other AssignedTo: unassig...@gcc.gnu.org ReportedBy: dan...@constexpr.org The following C++ code cause current gcc master to emit an incorrect array bounds warning: $ cat test.cpp struct type { bool a, b; bool get_b() { return b; } }; type stuff[9u]; void bar(); void foo() { for(unsigned i = 0u; i < 9u; i++) { if(!stuff[i].a) { continue; } bar(); for(unsigned j = i + 1u; j < 9u; j++) { if(stuff[j].a && stuff[j].get_b()) { return; } } } } $ g++-4.8.0-pre -Warray-bounds -O3 -c test.cpp test.cpp: In function ‘void foo()’: test.cpp:22:17: warning: array subscript is above array bounds [-Warray-bounds] if(stuff[j].a && stuff[j].get_b()) { ^ I appreciate static analyzers as much as everyone, but having false positives in the normal warnings (especially ones enabled at -Wall) can be annoying. GCC was build from git master just now: $ g++-4.8.0-pre -v Using built-in specs. COLLECT_GCC=g++-4.8.0-pre COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.0-pre/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-4.8.0_pre/work/gcc-4.8.0-/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.0-pre --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-pre/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-pre --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-pre/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-pre/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-pre/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --with-ppl --with-cloog --disable-ppl-version-check --with-cloog-include=/usr/include/cloog-ppl --enable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --enable-multilib --with-multilib-list=m32,m64 --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-pre/python --enable-checking=release --disable-libgcj --enable-libstdcxx-time --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.8.0_pre' Thread model: posix gcc version 4.8.0-pre 20130210 (experimental) commit bc85f3af1b43674782c9b5bb2240117f293b5530 (Gentoo 4.8.0_pre)
[Bug other/56273] [4.8 regression] Bogus -Warray-bounds warning
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273 --- Comment #1 from Daniel Scharrer 2013-02-10 07:07:40 UTC --- The same code and command-line arguments do not produce a warning in gcc 4.7.2, 4.6.3, 4.5.4 and clang 3.2 as well as clang's static analyzer.
[Bug libstdc++/56282] New: [4.8 regression] std::basic_ios broken with -std=c++11 (undefined reference)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56282 Bug #: 56282 Summary: [4.8 regression] std::basic_ios broken with -std=c++11 (undefined reference) Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: dan...@constexpr.org Simple enough: $ echo -e '#include \n int main() { std::cout << "Hello World!\\n"; return bool(std::cout); }' | g++-4.8.0-pre -x c++ - -std=c++11 /tmp/cc4QaOVU.o: In function `main': :(.text+0x19): undefined reference to `std::basic_ios >::operator bool() const' collect2: error: ld returned 1 exit status Broken by this commit: http://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=9d8eb68081f898e225727d69da8212813f27e199 The offending commit adds the correct test operator for C++11: +#if __cplusplus >= 201103L + explicit operator bool() const + { return !this->fail(); } +#else operator void*() const { return this->fail() ? 0 : const_cast(this); } +#endif However, std::basic_ios is explicitly instantiated in libstdc++.so (from basic_ios.tcc): #if _GLIBCXX_EXTERN_TEMPLATE extern template class basic_ios; #ifdef _GLIBCXX_USE_WCHAR_T extern template class basic_ios; #endif #endif So the gcc doesn't instantiate explicit operator bool for std::basic_ios and instead tries to use the instantiation in libstdc++.so, which only has the operator void*. $ g++-4.8.0-pre -v Using built-in specs. COLLECT_GCC=g++-4.8.0-pre COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.0-pre/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-4.8.0_pre/work/gcc-4.8.0-/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.0-pre --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-pre/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-pre --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-pre/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-pre/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-pre/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --with-ppl --with-cloog --disable-ppl-version-check --with-cloog-include=/usr/include/cloog-ppl --enable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --enable-multilib --with-multilib-list=m32,m64 --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-pre/python --enable-checking=release --disable-libgcj --enable-libstdcxx-time --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.8.0_pre' Thread model: posix gcc version 4.8.0-pre 20130211 (experimental) commit 37db34b1d053392f4d8899178a7f647bb70f400e (Gentoo 4.8.0_pre)
[Bug libstdc++/87618] New: Missing symbol for std::__cxx11::basic_stringbuf, std::allocator >::basic_stringbuf()
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87618 Bug ID: 87618 Summary: Missing symbol for std::__cxx11::basic_stringbuf, std::allocator >::basic_stringbuf() Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: daniel at constexpr dot org Target Milestone: --- $ cat stringbuf.cpp #include int main() { std::stringbuf sb; return 0; } $ g++ stringbuf.cpp /usr/bin/ld: /tmp/ccKu7olJ.o: in function `main': stringbuf.cpp:(.text+0x11): undefined reference to `std::__cxx11::basic_stringbuf, std::allocator >::basic_stringbuf()' collect2: error: ld returned 1 exit status $ g++ --version g++ (GCC) 9.0.0 20181014 (experimental) Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[Bug libstdc++/87618] [9 Regression] Missing symbol for std::__cxx11::basic_stringbuf, std::allocator >::basic_stringbuf()
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87618 --- Comment #4 from Daniel Scharrer --- Thanks, everything works for me now.
[Bug libstdc++/61269] New: includes inside std namespace
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61269 Bug ID: 61269 Summary: includes inside std namespace Product: gcc Version: 4.10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: daniel at constexpr dot org Partial diff from commit f2b58c906cf64f3e082bda9808b9f049bb71d5b4: --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -41,6 +41,15 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 +# if defined (__UINT_LEAST16_TYPE__) && defined(__UINT_LEAST32_TYPE__) + typedef __UINT_LEAST16_TYPE__ uint_least16_t; + typedef __UINT_LEAST32_TYPE__ uint_least32_t; +# else +# include +# endif +#endif Not reproducible with GCC as it defines __UINT_LEAST16_TYPE__ and __UINT_LEAST32_TYPE__ (at least on Linux amd64), but breaks with other compilers like Clang that end up on that #else branch.
[Bug libstdc++/61269] includes inside std namespace
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61269 --- Comment #5 from Daniel Scharrer --- Yes, after your fix everything works with Clang.
[Bug tree-optimization/107129] New: [13 Regression] False positive -Wstringop-overflow warning with -O2 or -O3
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107129 Bug ID: 107129 Summary: [13 Regression] False positive -Wstringop-overflow warning with -O2 or -O3 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: daniel at constexpr dot org Target Milestone: --- Created attachment 53652 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53652&action=edit Reduced testcase The attached testcase produces the following warning with GCC 13.0.0 20221002 (commit 3290dcf): $ /opt/gcc-dev/bin/c++ -O2 -c test.cpp test.cpp: In member function ‘void C::f()’: test.cpp:39:33: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 39 | c[i] = e(1.f - i, i); |~^~~~ test.cpp:9:23: note: at offset 1 into destination object ‘C4::r’ of size 1 9 | unsigned char r; |
[Bug tree-optimization/103986] New: Miscompilation with -O2 -funswitch-loops and __builtin_unreachable in ternary operator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103986 Bug ID: 103986 Summary: Miscompilation with -O2 -funswitch-loops and __builtin_unreachable in ternary operator Product: gcc Version: 10.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: daniel at constexpr dot org Target Milestone: --- Created attachment 52166 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52166&action=edit Reduced test case The loop in the attached reduced test case does not terminate when compiled with -O3 or -O2 -funswitch-loops with GCC 9.4.0 or GCC 10.3.1 even though it should only iterate 144 times. Curiously, the programs works as expected when using an if() instead of the ternary operator in the assume macro but maybe that's just luck. I could not reproduce the issue with GCC 8.5.0, GCC 11.2.1 or my GCC 12 checkout from 20220102.
[Bug tree-optimization/97953] [9/10 Regression] ICE (segfault) during GIMPLE pass: loopdone compiling libgcc/config/libbid/bid128_fma.c:190:1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97953 --- Comment #29 from Daniel Scharrer --- Hi, shouldn't this be Known to fail 10.3.**1** Known to work 10.3.**2**
[Bug c++/111159] New: [13 Regression] False positive -Wdangling-reference
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59 Bug ID: 59 Summary: [13 Regression] False positive -Wdangling-reference Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: daniel at constexpr dot org Target Milestone: --- GCC 13.2.0 as well as git from today report a false positive -Wdangling-reference warning for the following C++ code: struct A { int * i; int & b() { return *i; } }; int g = 42; A a() { return A{ &g }; } int main() { const int & i = a().b(); return i; }