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
Task Type Bug Report
Category Packages
Status Closed
Assigned To Sven-Hendrik Haase (Svenstaro)
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

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
Comment by Sven-Hendrik Haase (Svenstaro) - Wednesday, 27 May 2015, 10:51 GMT
Pretty sure I can't do anything here until nvidia gets its shit together. :/
Comment by Jakub Klinkovský (lahwaacz) - Wednesday, 27 May 2015, 13:56 GMT
I've dug in a little deeper and put together a failing example without using the STL:

============
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?
Comment by Sven-Hendrik Haase (Svenstaro) - Wednesday, 27 May 2015, 15:29 GMT
Oh wow wtf. But great information, I guess you can post on the dev forums.
Comment by Jakub Klinkovský (lahwaacz) - Wednesday, 27 May 2015, 16:46 GMT Comment by Sven-Hendrik Haase (Svenstaro) - Wednesday, 03 June 2015, 16:38 GMT Comment by Sven-Hendrik Haase (Svenstaro) - Wednesday, 03 June 2015, 16:39 GMT
Don't mention it's due to gcc 5.1 or otherwise they will just close it because they don't wanna go there yet. Make them aware that this is a problem in nvcc itself!
Comment by Jakub Klinkovský (lahwaacz) - Wednesday, 03 June 2015, 16:58 GMT
Sorry, I've been pretty busy since last week when I reported the bug to nvidia. Basically it is supposed to be already fixed in the development versions and the fix would be made available in the next CUDA release. They did not mention if they meant minor or major release :/
Comment by Sven-Hendrik Haase (Svenstaro) - Wednesday, 03 June 2015, 16:59 GMT
Oh well. Closing as upstream then if you don't disagree.
Comment by Jakub Klinkovský (lahwaacz) - Wednesday, 03 June 2015, 17:02 GMT
OK, we can only wait now...

Loading...