このバグを探していますが、見つけられないようです。
ヴァルグリンドは私にこう言います:
Uninitialised value was created by a heap allocation
==31732== at 0x4C28B35: operator new(unsigned long) (vg_replace_malloc.c:261)
==31732== by 0x406B87: __gnu_cxx::new_allocator<int>::allocate(unsigned long void const*) (in /home/matija/Documents/FER/6.semestar/dna-assembly/FMindex/src/test)
==31732== by 0x40560C: std::_Vector_base<int, std::allocator<int> >::_M_allocate(unsigned long) (in /home/matija/Documents/FER/6.semestar/dna-assembly/FMindex/src/test)
==31732== by 0x40497A: std::vector<int, std::allocator<int> >::_M_insert_aux(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, int const&) (in /home/matija/Documents/FER/6.semestar/dna-assembly/FMindex/src/test)
==31732== by 0x403B15: std::vector<int, std::allocator<int> >::push_back(int const&) (in /home/matija/Documents/FER/6.semestar/dna-assembly/FMindex/src/test)
==31732== by 0x413655: Compressor::getMTF(std::string const&) (in /home/matija/Documents/FER/6.semestar/dna-assembly/FMindex/src/test)
==31732== by 0x412EE4: Compressor::compress(std::string&) (in /home/matija/Documents/FER/6.semestar/dna-assembly/FMindex/src/test)
==31732== by 0x40E2FB: Opp::Opp(std::string&) (in /home/matija/Documents/FER/6.semestar/dna-assembly/FMindex/src/test)
==31732== by 0x402098: FMindex::FMindex(std::string&) (in /home/matija/Documents/FER/6.semestar/dna-assembly/FMindex/src/test)
==31732== by 0x41DE0B: main (in /home/matija/Documents/FER/6.semestar/dna-assembly/FMindex/src/test)
このコードの場合。このメッセージからわかる限り、ベクトルへのプッシュ中にエラーが発生したようですが、わかりません。また、「条件付きのジャンプまたは移動は、初期化されていない値に依存します」というエラーが1つ表示されます。これは、この結果だと思います。何か不足していますか?
vector<int> Compressor::getMTF(const string& L)
{
// Construct initial MTF list
list<char> MTFList = alphabet.toSortedList();
// Generate MTF code for L
vector<int> MTF;
for (int i = 0; i < L.length(); i++)
{
// If I am at the beginning of a bucket, store current MTF state
if (i % bucketSize == 0)
{
MTFStates.push_back(MTFList);
}
// Find position of L[i] in MTFList and encode it
list<char>::iterator it;
int pos = 0;
for (pos = 0, it = MTFList.begin(); it != MTFList.end(); it++, pos++)
if (*it == L[i])
{
MTF.push_back(pos);
MTFList.push_front(*it);
MTFList.erase(it);
break;
}
}
return MTF;
}