Closed Dobiasd closed 10 months ago
Release builds with optimizations and some additional bounds checks.
I continued to inline and chop off things in numeric_test.cpp
to arrive at this minimal example:
#include <vector>
std::vector<int> foo(const std::vector<int>& a)
{
if (a.size() < 2)
{
return a;
}
return a;
}
int main()
{
foo(std::vector<int>({1}));
}
The error still happens:
/usr/local/include/c++/13.2.0/bits/stl_algobase.h:437:30: error: 'void* __builtin_memmove(void*, const void*, long unsigned int)' forming offset 4 is out of the bounds [0, 4] [-Werror=array-bounds=]
So I guess it's a false positive.
This clumsy workaround fixes it: https://github.com/Dobiasd/FunctionalPlus/pull/280/commits/726e70866983b8c55c7240ed20e5c2d2cd61fc14
It only happens with -O3
, that's why we only see it with CMAKE_BUILD_TYPE=Release
.
I've opened a bug ticket here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111415
Interesting, GCC 13 fails:
One can reproduce it locally in Docker:
Funnily, replacing
with
makes it work: