Nvc++ error with <queue> and C++20 flag

Hi,

A C++ file containing only #include <queue> will fail to compile using nvc++, when the C++20 flag is present (-std=c++2a or -std=c++20). I am using 64-bit Ubuntu 20.10:

$ nvc++ -std=c++2a -c nvq.cpp 
"/usr/include/c++/10/bits/stl_queue.h", line 118: error: expected a "<"
        template<typename _Tp1, three_way_comparable _Seq1>
                                                     ^

"/usr/include/c++/10/bits/stl_queue.h", line 390: error: expected a "<"
    template<typename _Tp, three_way_comparable _Seq>
                                                ^

2 errors detected in the compilation of "nvq.cpp"

Hi PGK1,

Unfortunately I’m not sure what’s wrong. It appears to be either a compatibility issue or a problem with you GNU C++ header files.

Since we don’t support Ubuntu 20.10 (see: https://docs.nvidia.com/hpc-sdk/hpc-sdk-release-notes/index.html#supported-platforms) I don’t have a system to test this on. The code works fine on Ubuntu 20.04. I also configured the compiler to use GNU 10.1 and 10.2’s C++ header files, but both worked fine as well.

I’ll ask our IT folks to setup a VM with Ubuntu 20.10 and try again.

% cat nvq.cpp
#include <queue>
% g++ --version
g++ (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% nvc++ -std=c++2a -c test.cpp -V20.11
%

Thanks Mat. I looked a little deeper. It seems to be that <queue> uses the std::three_way_comparable concept when the -std=c++2a flag is there. Here is a smaller example which fails for me (NVC++ v20.11):

#include <compare>
static_assert(__cpp_lib_concepts);
static_assert(__cpp_lib_three_way_comparison);
static_assert(std::three_way_comparable<int>);

template <std::three_way_comparable T> // only error is here
struct Foo {};

Thanks PGK1. I’m now able to reproduce the error. Turns out that I had a misconfiguration so wasn’t actually using the GNU 10.2 header files.

The error appears to the a front end bug in EDG’s implementation of “concepts”. We’ve sent them a bug report and are tracking the issue internally as TPR #29468.

Unfortunately, no work around is available.

Note that C++20 support is still in development and incomplete, though we expected “concepts” to work.

1 Like

Thanks, that’s great. I do use C++20 and concepts, but this isn’t a blocker for me.