The trivial parallel STL example from the documentation (https://gcc.gnu.org/onlinedocs/libstdc++/manual/parallel_mode_using.html) does not compile with GCC 7.1.0 or 8.0.0 (compiled on June 4, 2017). $ cat test.cc #include <vector> #include <parallel/algorithm> int main() { std::vector<int> v(100); __gnu_parallel::sort(v.begin(), v.end()); return 0; } $ g++-8 -v Using built-in specs. COLLECT_GCC=g++-8 COLLECT_LTO_WRAPPER=/opt/gcc/HEAD/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /opt/gcc//git/configure --program-suffix=-8 --disable-multilib --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --enable-languages=c,c++,fortran --with-tune=native --enable-bootstrap --enable-lto --enable-gold=yes --enable-ld=yes --prefix=/opt/gcc//HEAD Thread model: posix gcc version 8.0.0 20170604 (experimental) (GCC) $ g++-8 -std=gnu++17 -g -O3 -mtune=native -D_GLIBCXX_PARALLEL -fopenmp test.cc In file included from /opt/gcc/HEAD/include/c++/8.0.0/algorithm:62:0, from /opt/gcc/HEAD/include/c++/8.0.0/parallel/algorithm:34, from test.cc:2: /opt/gcc/HEAD/include/c++/8.0.0/bits/stl_algo.h: In function ‘_SampleIterator std::__cxx1998::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)’: /opt/gcc/HEAD/include/c++/8.0.0/bits/stl_algo.h:5834:19: error: ‘__sample’ is not a member of ‘std’ return std::__sample(__first, __last, __pop_cat{}, __out, __samp_cat{}, ^~~~~~~~ /opt/gcc/HEAD/include/c++/8.0.0/bits/stl_algo.h:5834:19: note: suggested alternative: ‘is_same’ return std::__sample(__first, __last, __pop_cat{}, __out, __samp_cat{}, ^~~~~~~~ is_same $ g++-7 -v Using built-in specs. COLLECT_GCC=g++-7 COLLECT_LTO_WRAPPER=/opt/gcc/7.1.0/libexec/gcc/x86_64-pc-linux-gnu/7.1.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --prefix=/opt/gcc/7.1.0 --program-suffix=-7 --enable-shared --enable-static --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --enable-languages=c,c++,fortran --with-tune=native --enable-bootstrap --enable-lto --enable-gold=yes --enable-ld=yes --disable-multilib Thread model: posix gcc version 7.1.0 (GCC) $ g++-7 -std=gnu++17 -g -O3 -mtune=native -D_GLIBCXX_PARALLEL -fopenmp test.cc In file included from /opt/gcc/7.1.0/include/c++/7.1.0/algorithm:62:0, from /opt/gcc/7.1.0/include/c++/7.1.0/parallel/algorithm:34, from test.cc:2: /opt/gcc/7.1.0/include/c++/7.1.0/bits/stl_algo.h: In function ‘_SampleIterator std::__cxx1998::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)’: /opt/gcc/7.1.0/include/c++/7.1.0/bits/stl_algo.h:5812:19: error: ‘__sample’ is not a member of ‘std’ return std::__sample(__first, __last, __pop_cat{}, __out, __samp_cat{}, ^~~~~~~~ /opt/gcc/7.1.0/include/c++/7.1.0/bits/stl_algo.h:5812:19: note: suggested alternative: ‘is_same’ return std::__sample(__first, __last, __pop_cat{}, __out, __samp_cat{}, ^~~~~~~~ is_same It does not build with the standard namespace either... $ cat test.cc c #include <vector> #include <parallel/algorithm> int main() { std::vector<int> v(100); std::sort(v.begin(), v.end()); return 0; } $ g++-7 -std=gnu++17 -g -O3 -mtune=native -D_GLIBCXX_PARALLEL -fopenmp test.cc In file included from /opt/gcc/7.1.0/include/c++/7.1.0/algorithm:62:0, from /opt/gcc/7.1.0/include/c++/7.1.0/parallel/algorithm:34, from test.cc:2: /opt/gcc/7.1.0/include/c++/7.1.0/bits/stl_algo.h: In function ‘_SampleIterator std::__cxx1998::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)’: /opt/gcc/7.1.0/include/c++/7.1.0/bits/stl_algo.h:5812:19: error: ‘__sample’ is not a member of ‘std’ return std::__sample(__first, __last, __pop_cat{}, __out, __samp_cat{}, ^~~~~~~~ /opt/gcc/7.1.0/include/c++/7.1.0/bits/stl_algo.h:5812:19: note: suggested alternative: ‘is_same’ return std::__sample(__first, __last, __pop_cat{}, __out, __samp_cat{}, ^~~~~~~~ is_same $ g++-8 -std=gnu++17 -g -O3 -mtune=native -D_GLIBCXX_PARALLEL -fopenmp test.cc In file included from /opt/gcc/HEAD/include/c++/8.0.0/algorithm:62:0, from /opt/gcc/HEAD/include/c++/8.0.0/parallel/algorithm:34, from test.cc:2: /opt/gcc/HEAD/include/c++/8.0.0/bits/stl_algo.h: In function ‘_SampleIterator std::__cxx1998::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)’: /opt/gcc/HEAD/include/c++/8.0.0/bits/stl_algo.h:5834:19: error: ‘__sample’ is not a member of ‘std’ return std::__sample(__first, __last, __pop_cat{}, __out, __samp_cat{}, ^~~~~~~~ /opt/gcc/HEAD/include/c++/8.0.0/bits/stl_algo.h:5834:19: note: suggested alternative: ‘is_same’ return std::__sample(__first, __last, __pop_cat{}, __out, __samp_cat{}, ^~~~~~~~ is_same
This should fix it: --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -5831,8 +5831,9 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO "sample size must be an integer type"); typename iterator_traits<_PopulationIterator>::difference_type __d = __n; - return std::__sample(__first, __last, __pop_cat{}, __out, __samp_cat{}, - __d, std::forward<_UniformRandomBitGenerator>(__g)); + return _GLIBCXX_STD_A:: + __sample(__first, __last, __pop_cat{}, __out, __samp_cat{}, __d, + std::forward<_UniformRandomBitGenerator>(__g)); } #endif // C++17 #endif // C++14
Thank you! Indeed, that fixes it, both when applied directly to the installed header and when integrated into a build of the latest version. $ g++-8 -std=gnu++17 -g -O3 -mtune=native -D_GLIBCXX_PARALLEL -fopenmp test.cc&& echo "SUCCESS" || echo "FAIL" SUCCESS $ g++-8 -v Using built-in specs. COLLECT_GCC=g++-8 COLLECT_LTO_WRAPPER=/opt/gcc/HEAD/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /opt/gcc//git/configure --program-suffix=-8 --disable-multilib --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --enable-languages=c,c++,fortran --with-tune=native --enable-bootstrap --enable-lto --enable-gold=yes --enable-ld=yes --prefix=/opt/gcc//HEAD : (reconfigured) /opt/gcc//git/configure --program-suffix=-8 --disable-multilib --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --enable-languages=c,c++,fortran --with-tune=native --enable-bootstrap --enable-lto --enable-gold=yes --enable-ld=yes --prefix=/opt/gcc//HEAD Thread model: posix gcc version 8.0.0 20170627 (experimental) (GCC)
Author: redi Date: Tue Jun 27 14:44:50 2017 New Revision: 249692 URL: https://gcc.gnu.org/viewcvs?rev=249692&root=gcc&view=rev Log: PR libstdc++/81221 fix namespace qualification for parallel mode PR libstdc++/81221 * include/bits/stl_algo.h (sample): Qualify with _GLIBCXX_STD_A not std. * testsuite/25_algorithms/sample/81221.cc: New. Added: trunk/libstdc++-v3/testsuite/25_algorithms/sample/81221.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/bits/stl_algo.h
Author: redi Date: Tue Jun 27 16:19:16 2017 New Revision: 249697 URL: https://gcc.gnu.org/viewcvs?rev=249697&root=gcc&view=rev Log: PR libstdc++/81221 only run new test for check-parallel PR libstdc++/81221 * testsuite/25_algorithms/sample/81221.cc: Disable except for check-parallel. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/testsuite/25_algorithms/sample/81221.cc
Author: redi Date: Tue Jun 27 16:23:46 2017 New Revision: 249698 URL: https://gcc.gnu.org/viewcvs?rev=249698&root=gcc&view=rev Log: PR libstdc++/81221 fix namespace qualification for parallel mode PR libstdc++/81221 * include/bits/stl_algo.h (sample): Qualify with _GLIBCXX_STD_A not std. * testsuite/25_algorithms/sample/81221.cc: New. Added: branches/gcc-7-branch/libstdc++-v3/testsuite/25_algorithms/sample/81221.cc Modified: branches/gcc-7-branch/libstdc++-v3/ChangeLog branches/gcc-7-branch/libstdc++-v3/include/bits/stl_algo.h
Fixed for 7.2