[Bug c++/107532] [13 Regression] -Werror=dangling-reference false positives in libcamera-0.0.1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107532 --- Comment #20 from Rolf Eike Beer --- I'm running this rev: g++-13 (Gentoo 13.0.1. p, commit 27495bc8fe028d4a68e97ad12b52231772e48dcf) 13.0.1 20230308 (experimental) And I still get a warning for this testcase: // $ cat ref.cpp #include const std::string &trigger(const std::string &server); int verifyDevXml() { const auto &str = trigger(""); if (str.empty()) return 1; return 0; } // $ g++-13 -Wdangling-reference -c -o ref.o ref.cpp ref.cpp: In function ?int verifyDevXml()?: ref.cpp:7:15: warning: possibly dangling reference to a temporary [-Wdangling-reference] 7 | const auto &str = trigger(""); | ^~~ ref.cpp:7:28: note: the temporary was destroyed at the end of the full expression ?trigger(std::__cxx11::basic_string(((const char*)""), std::allocator()))? 7 | const auto &str = trigger(""); | ~~~^~~~ The problem is to my understanding that this warns about the temporary constructed in the argument, i.e. it warns that the std::string() formed from "" could be bound here. Which could be true if the function does that, but in my case it is just used as a lookup for a map and not returned.
[Bug c++/104012] New: -Wformat-truncation warnings not taking previous length check into account
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104012 Bug ID: 104012 Summary: -Wformat-truncation warnings not taking previous length check into account Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: e...@sf-mail.de Target Milestone: --- This code is from CMake's Source/cmLocalUnixMakefileGenerator3.cxx: std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable( std::string const& s, std::string const& s2) { […] char buffer[5]; int ni = 0; snprintf(buffer, sizeof(buffer), "%04d", ni); ret = str1 + str2 + buffer; while (this->ShortMakeVariableMap.count(ret) && ni < 1000) { ++ni; snprintf(buffer, sizeof(buffer), "%04d", ni); ret = str1 + str2 + buffer; } The second snprintf() causes this warning: …/CMake/Source/cmLocalUnixMakefileGenerator3.cxx:1311:41: warning: '%04d' directive output may be truncated writing between 4 and 11 bytes into a region of size 5 [-Wformat-truncation=] 1311 | snprintf(buffer, sizeof(buffer), "%04d", ni); | ^~~~ …/CMake/Source/cmLocalUnixMakefileGenerator3.cxx:1311:40: note: directive argument in the range [-2147483647, 2147483647] 1311 | snprintf(buffer, sizeof(buffer), "%04d", ni); |^~ The second warning line shows that the argument range is not correctly limited to [0, 1000], which would have avoided the warning. A similar warning is shown ~30 lines earlier in the same file for basically the same code. My current version is: gcc-12.0.0 (Gentoo 12.0.0_pre p2, commit 8b35f02ed599a70cce752e3cb544a7c9f808fce8) 12.0.0 20220111 (experimental) The version used previously has been built on 2021-08-14T20:47:39 and didn't show that warning.
[Bug tree-optimization/104012] [12 regression] -Wformat-truncation warnings not taking previous length check into account
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104012 --- Comment #2 from Rolf Eike Beer --- Created attachment 52182 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52182&action=edit preprocessed source
[Bug tree-optimization/104012] [12 regression] -Wformat-truncation warnings not taking previous length check into account
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104012 --- Comment #4 from Rolf Eike Beer --- I have rebuilt gcc today, now at commit b77e3b4e4589e56c01511fabdbaadb029cd47f5c. Configuration line: /var/tmp/portage/sys-devel/gcc-12.0.0_pre/work/gcc-12.0.0_pre/configure --host=sparc-unknown-linux-gnu --build=sparc-unknown-linux-gnu --prefix=/usr --bindir=/usr/sparc-unknown-linux-gnu/gcc-bin/12.0.0 --includedir=/usr/lib/gcc/sparc-unknown-linux-gnu/12.0.0/include --datadir=/usr/share/gcc-data/sparc-unknown-linux-gnu/12.0.0 --mandir=/usr/share/gcc-data/sparc-unknown-linux-gnu/12.0.0/man --infodir=/usr/share/gcc-data/sparc-unknown-linux-gnu/12.0.0/info --with-gxx-include-dir=/usr/lib/gcc/sparc-unknown-linux-gnu/12.0.0/include/g++-v12 --with-python-dir=/share/gcc-data/sparc-unknown-linux-gnu/12.0.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --disable-nls --disable-libunwind-exceptions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion=Gentoo 12.0.0_pre, commit b77e3b4e4589e56c01511fabdbaadb029cd47f5c --disable-esp --enable-libstdcxx-time --disable-libstdcxx-pch --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libssp --disable-libada --disable-cet --disable-systemtap --disable-valgrind-annotations --disable-vtable-verify --disable-libvtv --without-zstd --enable-lto --with-isl --disable-isl-version-check --enable-default-pie --enable-default-ssp I can still trigger the warning: cd /tmp/cmtest/Source && /usr/bin/c++ -DCURL_STATICLIB -DLIBARCHIVE_STATIC -D_FILE_OFFSET_BITS=64 -I/tmp/cmtest/Utilities -I/tmp/cmtest/Source -I/home/buildbot/repos/CMake/Source -I/home/buildbot/repos/CMake/Source/LexerParser -I/home/buildbot/repos/CMake/Source/CTest -I/home/buildbot/repos/CMake/Source/CPack -isystem /home/buildbot/repos/CMake/Utilities/std -isystem /home/buildbot/repos/CMake/Utilities -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W -Wshadow -Wpointer-arith -Wformat-security -Wundef -g -std=c++17 -MD -MT Source/CMakeFiles/CMakeLib.dir/cmLocalUnixMakefileGenerator3.cxx.o -MF CMakeFiles/CMakeLib.dir/cmLocalUnixMakefileGenerator3.cxx.o.d -o CMakeFiles/CMakeLib.dir/cmLocalUnixMakefileGenerator3.cxx.o -c /home/buildbot/repos/CMake/Source/cmLocalUnixMakefileGenerator3.cxx -Wformat-truncation=2 I still have the full gcc build log if that matters.
[Bug middle-end/104069] -Werror=use-after-free false positive on elfutils-0.186
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104069 Rolf Eike Beer changed: What|Removed |Added CC||e...@sf-mail.de --- Comment #23 from Rolf Eike Beer --- Using gcc12 from 4943b75e9f06f0b64ed541430bb7fbccf55fc552. $ cat rea.c #include char * compact_buffer(char *inbuf, size_t oldlen, size_t k) { char *foo; #ifdef WARN char **buf = &foo; #endif foo = realloc(inbuf, k); if (foo == NULL) { #if defined(WARN) && defined(WARN2) foo = inbuf; return inbuf; #else return inbuf; #endif } return foo; } $ gcc-12.0.1 -c -Wuse-after-free=3 -Irepos/Qsmtp/include rea.c $ gcc-12.0.1 -c -DWARN -Wuse-after-free=2 -Irepos/Qsmtp/include rea.c rea.c: In function 'compact_buffer': rea.c:17:24: warning: pointer 'inbuf' may be used after 'realloc' [-Wuse-after-free] 17 | return inbuf; |^ rea.c:11:15: note: call to 'realloc' here 11 | foo = realloc(inbuf, k); | ^ $ gcc-12.0.1 -c -DWARN -DWARN2 -Wuse-after-free=2 -Irepos/Qsmtp/include rea.c rea.c: In function 'compact_buffer': rea.c:15:24: warning: pointer 'inbuf' may be used after 'realloc' [-Wuse-after-free] 15 | return inbuf; |^ rea.c:11:15: note: call to 'realloc' here 11 | foo = realloc(inbuf, k); | ^ rea.c:14:21: warning: pointer 'inbuf' may be used after 'realloc' [-Wuse-after-free] 14 | foo = inbuf; | ^~~ rea.c:11:15: note: call to 'realloc' here 11 | foo = realloc(inbuf, k); | ^
[Bug bootstrap/111642] [14 Regression] profiledbootstrap failure: poly-int.h:453:5: error: too many initializers for ‘long int [1]’ (possibly since r14-4339-geaa41a6dc127d8)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111642 Rolf Eike Beer changed: What|Removed |Added CC||e...@sf-mail.de --- Comment #2 from Rolf Eike Beer --- Just hit the one in simplify-rtx.cc on Linux/sparc64: In file included from /var/tmp/portage/sys-devel/gcc-14.0.0./work/gcc-14.0.0./gcc/coretypes.h:480, from /var/tmp/portage/sys-devel/gcc-14.0.0./work/gcc-14.0.0./gcc/simplify-rtx.cc:23: /var/tmp/portage/sys-devel/gcc-14.0.0./work/gcc-14.0.0./gcc/poly-int.h: In instantiation of ‘constexpr poly_int::poly_int(poly_int_full, const Cs& ...) [with Cs = {int, int}; unsigned int N = 1; C = long int]’: /var/tmp/portage/sys-devel/gcc-14.0.0./work/gcc-14.0.0./gcc/poly-int.h:439:13: required from here /var/tmp/portage/sys-devel/gcc-14.0.0./work/gcc-14.0.0./gcc/simplify-rtx.cc:8692:25: in ‘constexpr’ expansion of ‘poly_int<1, long int>(1, 1)’ /var/tmp/portage/sys-devel/gcc-14.0.0./work/gcc-14.0.0./gcc/poly-int.h:453:5: error: too many initializers for ‘long int [1]’ 453 | : coeffs { (typename poly_coeff_traits:: | ^ 454 | template init_cast::type (cs))... } {} | ~~~