DescriptionRoel van de Kraats
2023-04-21 07:05:24 UTC
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
Comment 1Roel van de Kraats
2023-04-21 07:07:06 UTC
Comment 2Roel van de Kraats
2023-05-01 11:38:38 UTC
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
Comment 3Roel van de Kraats
2023-08-02 15:27:30 UTC
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.
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