http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52725

--- Comment #4 from Steffen Möller <steffen_moeller at gmx dot de> 2012-05-29 
10:33:36 UTC ---
Hello, this took me a while.

It seems like the problem is in (or in the interaction with) nvcc, the NVidia
compiler. For that you program for the graphics card and the host processor at
the same time. The .cu files indicate such files that are not meant to be seen
by the regular compiler at a first sight. It then generates preprocessed files
for gcc to digest.

$ rm -f t.cu_OpenMMCuda_generated.cpp; /usr/bin/nvcc t.cu -cuda -o
t.cu_OpenMMCuda_generated.cpp && g++ -c t.cu_OpenMMCuda_generated.cpp
t.cu: In member function ‘void CUDAStream<T>::Allocate()’:
t.cu:12:27: error: capture of non-variable ‘CUDAStream<T>::_subStreams’ 
t.cu:4:10: note: ‘unsigned int CUDAStream<T>::_subStreams’ declared here

$ cat t.cu
template <typename T>
struct CUDAStream
{
    unsigned int    _subStreams;
    T**             _pSysStream;
    void Allocate();
};

template <typename T>
void CUDAStream<T>::Allocate()
{
    _pSysStream =   new T*[_subStreams];
}


The NVCC-generated code now has the ()s again:

# 9 "t.cu"
template< class T> void
# 10 "t.cu"
CUDAStream< T> ::Allocate()
# 11 "t.cu"
{
# 12 "t.cu"
(_pSysStream) = (new (T *[_subStreams]));
# 13 "t.cu"
}

4.6 crunges it, 4.7 does not. Sounds like we should prepare an email to NVidia.
Anybody with any direct contacts?

Thanks

Steffen

Reply via email to