lion03 / thrust

Automatically exported from code.google.com/p/thrust
Apache License 2.0
0 stars 0 forks source link

Cannot compile with the PGI C++ compiler #333

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Please post a short, self-contained code sample which reproduces the
problem:

#define THRUST_DEVICE_BACKEND 2
#include <thrust/tuple.h>
#include <thrust/host_vector.h>
#include <thrust/binary_search.h>

int main(int argc, char** argv)
{
  typedef thrust::tuple<int,int> int2;
  thrust::host_vector<int2> input(5);

  input[0] = int2(0,0);
  input[1] = int2(2,0);
  input[2] = int2(5,0);
  input[3] = int2(7,0);
  input[4] = int2(8,0);

  thrust::host_vector<thrust::tuple<int,int> > values(6);
  values[0] = int2(0,0); 
  values[1] = int2(1,0);
  values[2] = int2(2,0);
  values[3] = int2(3,0);
  values[4] = int2(8,0);
  values[5] = int2(9,0);

  thrust::host_vector<int> output(6);

  thrust::lower_bound(input.begin(), input.end(),
                      values.begin(), values.end(), 
                      output.begin());
}

What is the expected output? What do you see instead?

It should compile.  Instead, I get error messages that more than one instance 
of overloaded function "std::distance"  matches the argument list', likewise 
for std::advance.   Please see the attached files for details.

What version of Thrust are you using?

changeset:   1409:7ded38be1741
branch:      1.4.0
user:        jaredhoberock
date:        Tue Mar 08 11:02:52 2011 -0800
summary:     Add branch 1.4.0

Which version of nvcc? 

N/A, I am compiling a pure C++ code with host_vector.

Which host compiler? On what operating system? 

mayhem% pgCC --version
pgCC 10.9-0 64-bit target on x86-64 Linux -tp nehalem-64 

Which GPU? 
N/A

Original issue reported on code.google.com by andrew.c...@gmail.com on 21 Apr 2011 at 11:20

Attachments:

GoogleCodeExporter commented 8 years ago
This is PGI's bug.  Their STL implementation should not make unqualified calls 
to functions, which causes ADL [1].

Try editing your vendor's STL to replace calls to distance() with 
std::distance().

[1] http://en.wikipedia.org/wiki/Argument-dependent_name_lookup

Original comment by jaredhoberock on 21 Apr 2011 at 4:56