https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127625

maic <gnu.ojxq8 at dralias dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gnu.ojxq8 at dralias dot com

--- Comment #1 from maic <gnu.ojxq8 at dralias dot com> ---
The comment and the reproducer is quite verbose. I think a smaller repro would
be:

https://godbolt.org/z/GEMc4eEW9

Basically compile the code with -O2 -std=c++20 -Wall :

#include <cstddef>
#include <memory>
#include <vector>
void memory_cleanse(void* ptr, std::size_t len);
template <typename T>
struct zero_after_free_allocator : std::allocator<T> {
    void deallocate(T* ptr, std::size_t n)
    {
        memory_cleanse(ptr, sizeof(T) * n);
        std::allocator<T>::deallocate(ptr, n);
    }
};
void bip32_array_bounds_repro()
{
    unsigned char fingerprint[4]{};
    std::vector<unsigned char, zero_after_free_allocator<unsigned char>> data;
    data.emplace_back();
    data.insert(data.end(), fingerprint, fingerprint + 4);
    data.insert(data.end(), fingerprint, fingerprint + 4);
}

Reply via email to