C++ test program test.cpp: #include <vector> void test(std::vector<unsigned char> & dest, std::vector<unsigned char> const& src) { if (not dest.empty()) { dest.insert(dest.end(), src.begin(), src.end()); } } Compile with: g++ -Wall -O2 -o test.cpp.o -c test.cpp Gives: ... /usr/include/c++/13/bits/stl_algobase.h:437:30: warning: ‘void* __builtin_memmove(void*, const void*, long unsigned int)’ writing between 2 and 9223372036854775807 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=] ... Please note that this warning doesn't occur when the if() statement is removed. g++ (GCC) 13.0.1 20230401 (Red Hat 13.0.1-0) gcc-c++-13.0.1-0.12.fc38.x86_64 libstdc++-devel-13.0.1-0.12.fc38.x86_64 Reproducible: Always Steps to Reproduce: 1.See Details 2. 3. Actual Results: Compiler produces a warning (29 lines in total) Expected Results: No warning g++ 12.2.1 on Fedora 37 doesn't produce this warning
Created attachment 1958759 [details] Compiler output
Issue still occurs with the latest F38 gcc-c++ package: g++ (GCC) 13.1.1 20230426 (Red Hat 13.1.1-1) gcc-c++-13.1.1-1.fc38.x86_64 libstdc++-devel-13.1.1-1.fc38.x86_64
Issue still occurs with gcc 13.2: g++ (GCC) 13.2.1 20230728 (Red Hat 13.2.1-1) gcc-c++-13.2.1-1.fc38.x86_64 libstdc++-devel-13.2.1-1.fc38.x86_64 Please let me know if I should report this issue upstream instead.
This message is a reminder that Fedora Linux 38 is nearing its end of life. Fedora will stop maintaining and issuing updates for Fedora Linux 38 on 2024-05-21. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a 'version' of '38'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, change the 'version' to a later Fedora Linux version. Note that the version field may be hidden. Click the "Show advanced fields" button if you do not see it. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora Linux 38 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora Linux, you are encouraged to change the 'version' to a later version prior to this bug being closed.
Updated 'version' to 39, as it is still seen with: gcc-c++-13.2.1-7.fc39.x86_64 libstdc++-devel-13.2.1-7.fc39.x86_64
Issue also occurs on F40, with gcc 14: g++ (GCC) 14.0.1 20240411 (Red Hat 14.0.1-0) gcc-c++-14.0.1-0.15.fc40.x86_64 libstdc++-devel-14.0.1-0.15.fc40.x86_64
Issue still occurs with gcc 14.2: g++ (GCC) 14.2.1 20240801 (Red Hat 14.2.1-1) gcc-14.2.1-1.fc40.x86_64 libstdc++-devel-14.2.1-1.fc40.x86_64
Issue still occurs with gcc 14.2.1 on F41: g++ (GCC) 14.2.1 20250110 (Red Hat 14.2.1-7) gcc-14.2.1-7.fc41.x86_64 libstdc++-devel-14.2.1-7.fc41.x86_64
Yay! The problem is solved with gcc 14.3.1. Tested on F41 with: g++ (GCC) 14.3.1 20250523 (Red Hat 14.3.1-1) No warning is shown anymore with the same test program and compile command. And the same with gcc 15.1.1 on F42: g++ (GCC) 15.1.1 20250521 (Red Hat 15.1.1-2) Closing ticket.
This was fixed by https://gcc.gnu.org/r14-11508-g4366711d2d66ea upstream