I ran into this bug which seems to be triggered when deleting the last element from packed_spsi. It seems the last element cannot be a non-zero element in this specific instance. If I set the last element to zero before removing it, it seems to work fine (see the comment out code below). A similar issue seems to have been closed before so I'm not sure if this is related to that.
The following code should replicate the bug:
#include <iostream>
#include <random>
#include "dynamic/dynamic.hpp"
using namespace std;
using namespace dyn;
int main() {
packed_spsi my_spsis;
std::random_device rd;
std::mt19937 mt(rd());
std::uniform_int_distribution<std::mt19937::result_type> dist6(0,100);
cout << "Inserting random values: \n";
for (int i = 0; i < 2000; ++i) {
auto rand_val = static_cast<unsigned int>(dist6(mt));
cout << i << ". Inserting val " << rand_val << "\n";
my_spsis.push_back(rand_val);
}
cout << "Deleting random values: \n";
for (int i = 0; i < 2000; ++i) {
cout << i << ". Deleting \n";
assert(my_spsis.size() > 0);
// Uncomment to avoid the bug
// if (my_spsis.size() == 1){
// my_spsis.set(0, 0);
// }
my_spsis.remove(0);
}
}
Hi there @nicolaprezza,
I ran into this bug which seems to be triggered when deleting the last element from
packed_spsi
. It seems the last element cannot be a non-zero element in this specific instance. If I set the last element to zero before removing it, it seems to work fine (see the comment out code below). A similar issue seems to have been closed before so I'm not sure if this is related to that.The following code should replicate the bug:
Hope this gets fixed soon. Thank you.