Bonjour,
j'ai un problème avec un "dictionnaire" qui me cause un segfault lorsque je tente d'accéder à un élément uniquement en Release (netbeans).
Le code:
Le backtrace GDB:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 unsigned long getId(std::string entry) std::map<std::string, unsigned long>::iterator it; it = this->dict->find(entry); if (it != this->dict->end()) { debug("Value is: " + it->second, DDEBUG); <--- SEGFAULT return it->second; } else { debug("Substring ->" + entry + "<- not found in dictionary", DDEBUG); return 0; }
La seule option supplémentaire qu'il y a en Release est
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 #0 0x00007ffff735f061 in strlen () from /lib/libc.so.6 #1 0x00007ffff7b7a220 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) () from /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/libstdc++.so.6 #2 0x0000000000404c1c in ...::getId(std::string) () #3 0x000000000040519e in ...::Method1(std::string const*) () #4 0x0000000000402f8c in main ()Serait-ce cette optimisation qui décide de supprimer les éléments de mon map ?-O2
Options complètes:g++ -m64 -g -c -g -O2 -Wall -MMD -MP -MF
A noter que si je commente la ligne en question, la valeur retournée est correcte et mon programme se termine correctement....
Partager