https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81221

            Bug ID: 81221
           Summary: stl_algo.h: error: ‘__sample’ is not a member of ‘std’
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jeff.science at gmail dot com
  Target Milestone: ---

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

Reply via email to