[PATCH] Fix -Wstringop-overflow warning in 23_containers/vector/types/1.cc

François Dumont frs.dumont@gmail.com
Mon May 27 20:58:31 GMT 2024


Sure, I'll try to have a look.

But for the moment this patch introduces some regressions so I keep on 
working on it.

FAIL: 23_containers/vector/modifiers/moveable.cc  -std=gnu++14 execution 
test
FAIL: 23_containers/vector/modifiers/moveable2.cc  -std=gnu++14 
execution test

On 27/05/2024 22:18, Sam James wrote:
> François Dumont <frs.dumont@gmail.com> writes:
>
>> In C++98 this test fails with:
> For this, and your other -Wfree-nonheap-object patches, could you see if
> it helps with any of the bugs reported for both -Wstringop-overflow and
> -Wfree-nonheap-object in libstdc++? There's a bunch of (possible) dupes
> that it'd be worth tagging if any of them are applicable.
>
>> Excess errors:
>> /home/fdumont/dev/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_algobase.h:452:
>> warning: 'void* __builtin_memcpy(void*, const void*, long unsigned
>> int)' writing between 2 and 9223372036854775806 bytes into a region of
>> size 0 overflows the destination [-Wstringop-overflow=]
>>
>> The attached patch avoids this warning.
>>
>>      libstdc++: Fix -Wstringop-overflow warning coming from std::vector
>>
>>      Make vector<>::_M_range_insert implementation more transparent to
>> the compiler checks.
>>
>>      Extend local copies of members to the whole method scope so that
>> all branches benefit
>>      from those.
>>
>>      libstdc++-v3/ChangeLog:
>>
>>              * include/bits/vector.tcc
>>              (std::vector<>::_M_range_insert(iterator, _FwdIt, _FwdIt,
>> forward_iterator_tag)):
>>              Use local copies of members to call the different algorithms.
>>
>> Ok to commit if all tests passes ?
>>
>> François
>>
>> [2. text/plain; vector_range_insert_patch.txt]...


More information about the Libstdc++ mailing list