lundi 20 avril 2020

Getting a status 139 when using operator[] on unordered_map

The before last line of this code causes my program to crash with status 139.

int original_i = static_cast<int>((write_idx + offset) / word_prob_len);
int cid = int_to_cid_[original_i];
int_to_cid_.erase(original_i);
int new_i = static_cast<int>((write_idx) / word_prob_len);
int_to_cid_[new_i] = cid;
std::cerr << "C " << cid<<" "<<new_i<<std::endl;
cid_to_int_[cid] = new_i;  // THIS IS THE PROBLEM
std::cerr << "D"<<std::endl;

By using std::cerr I've found that line to be causing an error, and if I comment it out I don't get it anymore.

Why could this be happening? This code is inside a method of a class, and the only time I use cid_to_int_ is in the constructor where I initialize it with some entries.

Aucun commentaire:

Enregistrer un commentaire