Compilation fails of the small code sample found at: http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt12ch31s03.html
I am using the suggested compiler options. This is the code (cut and pasted from your documentation): #include <vector> #include <parallel/algorithm> int main() { std::vector<int> v(100); // ... // Explicitly force a call to parallel sort. __gnu_parallel::sort(v.begin(), v.end()); return 0; } If it is this code that is incorrect the docs should be fixed as there are not many examples of parallel libstdc++ usage to be found on the net at the moment. This is g++ output: g++ -v -save-temps -fopenmp -march=i686 -o test parallelsort.cpp Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.2-1ubuntu11' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu11) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-fopenmp' '-march=i686' '-o' 'test' '-shared-libgcc' '-pthread' /usr/lib/gcc/i486-linux-gnu/4.3.2/cc1plus -E -quiet -v -D_GNU_SOURCE -D_REENTRANT parallelsort.cpp -D_FORTIFY_SOURCE=2 -march=i686 -fopenmp -fpch-preprocess -o parallelsort.ii ignoring nonexistent directory "/usr/local/include/i486-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../i486-linux-gnu/include" ignoring nonexistent directory "/usr/include/i486-linux-gnu" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/4.3 /usr/include/c++/4.3/i486-linux-gnu /usr/include/c++/4.3/backward /usr/local/include /usr/lib/gcc/i486-linux-gnu/4.3.2/include /usr/lib/gcc/i486-linux-gnu/4.3.2/include-fixed /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-fopenmp' '-march=i686' '-o' 'test' '-shared-libgcc' '-pthread' /usr/lib/gcc/i486-linux-gnu/4.3.2/cc1plus -fpreprocessed parallelsort.ii -quiet -dumpbase parallelsort.cpp -march=i686 -auxbase parallelsort -version -fopenmp -fstack-protector -o parallelsort.s GNU C++ (Ubuntu 4.3.2-1ubuntu11) version 4.3.2 (i486-linux-gnu) compiled by GNU C version 4.3.2, GMP version 4.2.2, MPFR version 2.3.2. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: dc8f858cacda993dd8f70837f0d9565d /usr/include/c++/4.3/parallel/algo.h: In function void std::__parallel::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >]: parallelsort.cpp:11: instantiated from here /usr/include/c++/4.3/parallel/algo.h:1736: error: call of overloaded sort(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >&, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >&, std::less<int>) is ambiguous /usr/include/c++/4.3/parallel/algo.h:1741: note: candidates are: void std::__parallel::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, _Compare = std::less<int>] /usr/include/c++/4.3/bits/stl_algo.h:4806: note: void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, _Compare = std::less<int>] So it can't resolve the ambiguous overloading between a parallel and non-parallel version of sort. I am not sure which -march option i should be using, but i tried using none, -march=i686, and -march=native, with identical results. This is an up-to-date ubuntu 8.10, by the way. -- Summary: Parallel mode example code does not compile Product: gcc Version: 4.3.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: j dot s dot sebastian at gmail dot com GCC build triplet: i486-linux-gnu GCC host triplet: i486-linux-gnu GCC target triplet: i486-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38897