-
Notifications
You must be signed in to change notification settings - Fork 123
Closed
Description
Consider this test code:
#include <cstdint>
#include <string>
#include <boost/container/flat_map.hpp>
typedef boost::container::flat_map< std::uint8_t, std::string > my_map;
void add_element(std::string& str, char elem)
{
str.push_back(elem);
}
int main()
{
my_map m;
add_element(m[static_cast< std::uint8_t >(96u)], 'a');
add_element(m[static_cast< std::uint8_t >(102u)], 'a');
add_element(m[static_cast< std::uint8_t >(104u)], 'a');
}
g++ -O2 -I. -std=gnu++17 -o test_flat_map test_flat_map.cpp
This crashes with:
free(): invalid pointer
Aborted (core dumped)
valgrind also shows a number of invalid memory accesses, see the attached log:
This code works correctly in Boost 1.84.0. It also doesn't crash if compiled with -O0.
gcc 11.4.0, Kubuntu 22.04.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels