FS#45079 - [cuda] (in)compatibility with C++ standard library provided by GCC 5.1
Attached to Project:
Community Packages
Opened by Jakub Klinkovský (lahwaacz) - Monday, 25 May 2015, 14:26 GMT
Last edited by Sven-Hendrik Haase (Svenstaro) - Wednesday, 03 June 2015, 17:03 GMT
Opened by Jakub Klinkovský (lahwaacz) - Monday, 25 May 2015, 14:26 GMT
Last edited by Sven-Hendrik Haase (Svenstaro) - Wednesday, 03 June 2015, 17:03 GMT
|
Details
There are compatibility problems with the C++ standard
library provided by GCC since 5.1, specifically the
'streambuf' header file. Consider the following example
from
http://www.cplusplus.com/reference/streambuf/streambuf/
============ // swapping ostringstream objects #include <string> // std::string #include <iostream> // std::cout #include <sstream> // std::stringstream int main () { std::stringstream ss; ss << 100 << ' ' << 200; int foo,bar; ss >> foo >> bar; std::cout << "foo: " << foo << '\n'; std::cout << "bar: " << bar << '\n'; return 0; } ============ Save it as "test.cu" (not .cpp) and try to compile with -std=c++11. The error message says: $ nvcc -std=c++11 test.cu -o test /usr/include/c++/5.1.0/streambuf:827:59: error: expected ‘;’ before ‘=’ token Compilation without -std=c++11 succeeds, as well as compiling the example saved as .cpp file. Package versions: gcc 5.1.0-4, cuda 7.0.28-2 |
This task depends upon
Closed by Sven-Hendrik Haase (Svenstaro)
Wednesday, 03 June 2015, 17:03 GMT
Reason for closing: Upstream
Wednesday, 03 June 2015, 17:03 GMT
Reason for closing: Upstream
============
template<typename T>
class Foo
{
public:
Foo() {}
Foo(const Foo &);
};
// here it fails
template<typename T>
Foo<T>::Foo(const Foo &) = default;
int main () {
Foo<int> f;
return 0;
}
============
Again saving this as "test.cu" and compiling with nvcc -std=c++11 results in the same error:
$ nvcc -std=c++11 test.cu -o test
test.cu:11:44: error: expected ‘;’ before ‘=’ token
Compiling with --verbose --keep reveals that in a file produced by cudafe++ there is the following snippet:
# 10 "nvcc_test.cu"
template < typename T >
Foo < T > :: Foo ( const Foo & ) = default = default
which is not even a valid C++ code (by any standard) so throwing it to GCC results in the above error. The minimal example does not even compile on systems with older GCC, so nvcc worked only because this syntax was never used in the previous versions of the STL.
It's their shit indeed, but they don't have a bug tracker do they?
Posted in https://devtalk.nvidia.com/default/topic/836068/cuda-programming-and-performance/-bug-incompatibility-with-c-11-standard/