empty Map>. begin() returns NULL
Hello
I'm lost.. my code gets HARD-HANDLE due to illegal access, have traced it down to my MAP.
but have NO clue to why :(
My code have a map of shared pointers. with a key uint64_t.
A loop of the elements before any is added makes it crash.
now i can see the .begin() on my empty maps return NULL, WTF. I would not expect this to ever happen ?
The MAP looks to be created correct, and both left & right is set to "END"
but when using the begin(), it still return NULL
Now comes the wierd part... if i use uint32_t as key... it works :tired_face: and begin & end both return "end"
This is a reduced version in normal "c++"
my result on my STM32 is:
it32_1 : 0x24004700
it32_2 : 0x24004700
it64_1 : 0x0
it64_2 : 0x240046e5
// map::begin/end
#include <iostream>
#include <map>
#include <memory>
class test
{
public:
test(){};
~test(){};
};
int main ()
{
std::map<uint32_t, std::shared_ptr<test>> testMap32;
std::map<uint64_t, std::shared_ptr<test>> testMap64;
auto it32_1 = testMap32.begin();
auto it32_2 = testMap32.end();
auto it64_1 = testMap64.begin();
auto it64_2 = testMap64.end();
printf("it32_1 : %p\r\n",it32_1);
printf("it32_2 : %p\r\n",it32_2);
printf("it64_1 : %p\r\n",it64_1);
printf("it64_2 : %p\r\n",it64_2);
return 0;
}Is this a BUG in the compiler ???
I have updated to IDE 1.7
Update:
using key:
uint8_t Fails
uint16_t Success