Dear all,
I am certainly not an expert in C++ development but after some time, I had some code running and compiling for a bio-informatics tool. As always in Science, I changed my area of research of a while and when I came back to my tool, I had changed my computer (and my gcc version) in between.
In the program, I run several threads that call a function.
This is where the function run_es_pval is called (and where the error message takes place)
for (int i = 0; i < threadNb; i++) {
int start = i * datasetPerThread;
int end = start + datasetPerThread;
if (i == threadNb-1) {
end = datasetsSize;
}
threads.push_back(thread (run_es_pval, start, end, rankedSize, datasetNames, datasets, dicoArray,
es_threshold));
}
for (int i = 0; i < threadNb; i++) {
threads[i].join();
}
This is the definition of the run_es_pval function
void run_es_pval(int start, int end, int rankedSize, vector <string> &datasetNames, vector <vector <bool>>
&datasets, vector <string> &dicoArray, double es_threshold)
This is the command I usd for compilation
g++ -g -pthread -std=c++0x test.cpp
With gcc 4.5.0, this code compile without the least warning while with gcc 4.7.1 I have the following strange error.
In file included from /usr/include/c++/4.7/bits/move.h:57:0,
from /usr/include/c++/4.7/bits/stl_pair.h:61,
from /usr/include/c++/4.7/bits/stl_algobase.h:65,
from /usr/include/c++/4.7/bits/char_traits.h:41,
from /usr/include/c++/4.7/ios:41,
from /usr/include/c++/4.7/ostream:40,
from /usr/include/c++/4.7/iostream:40,
from compute_gsea_correct_negcontrol-rthreads_TEST.cpp:1:
/usr/include/c++/4.7/type_traits: In instantiation of ‘struct std::_Result_of_impl<false, false, void (*)(int, int, int, std::vector<std::basic_string<char> >&, std::vector<std::vector<bool> >&, std::vector<std::basic_string<char> >&, double), int, int, int, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, double>’:
/usr/include/c++/4.7/type_traits:1857:12: required from ‘class std::result_of<void (*(int, int, int, std::vector<std::basic_string<char> >, std::vector<std::vector<bool> >, std::vector<std::basic_string<char> >, double))(int, int, int, std::vector<std::basic_string<char> >&, std::vector<std::vector<bool> >&, std::vector<std::basic_string<char> >&, double)>’
/usr/include/c++/4.7/functional:1563:61: required from ‘struct std::_Bind_simple<void (*(int, int, int, std::vector<std::basic_string<char> >, std::vector<std::vector<bool> >, std::vector<std::basic_string<char> >, double))(int, int, int, std::vector<std::basic_string<char> >&, std::vector<std::vector<bool> >&, std::vector<std::basic_string<char> >&, double)>’
/usr/include/c++/4.7/thread:133:9: required from ‘std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (&)(int, int, int, std::vector<std::basic_string<char> >&, std::vector<std::vector<bool> >&, std::vector<std::basic_string<char> >&, double); _Args = {int&, int&, int&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, double&}]’
compute_gsea_correct_negcontrol-rthreads_TEST.cpp:757:116: required from here
/usr/include/c++/4.7/type_traits:1834:9: error: invalid initialization of non-const reference of type ‘std::vector<std::basic_string<char> >&’ from an rvalue of type ‘std::vector<std::basic_string<char> >’
From what I read on Internet, I saw that it might be linked to some vector that are not const! Any idea?
I thank you all very much for having taken the time of reading me... please don't tell me to get back to Perl that I should never have left like the dirty biologist I am :-)
Cheers,
Sylvain