pgc++ 18.10 cannot compile shared_ptr

I have:

pgc++ --version
pgc++ 18.10-1 64-bit target on x86-64 Linux -tp sandybridge
PGI Compilers and Tools
Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.

and a simple test code

#include <memory> 
#include <vector> 
#include <cstddef> 

size_t size(); 
void x() { 
std::size_t n=2; 
std::shared_ptr<std::vector<double> > p = std::make_shared<std::vector<double> >(n); 
std::shared_ptr<std::vector<double> > q = std::make_shared<std::vector<double> >(size()); 
std::shared_ptr<std::vector<double> > r = std::make_shared<std::vector<double> >((n=size())); 
std::vector<double>* s = new std::vector<double>(size()); 
}

Compiling with pgc++ gave me:

pgc++ --c++11 -c test.cpp
“./test.cpp”, line 8: error: namespace “std” has no member “shared_ptr”
std::shared_ptr<std::vector > p = std::make_shared<std::vector >(n);

Why?
Thanks!

Hi VYU,

I’m able to compile this file here so I suspect something else is wrong.

What version of g++ do you have installed? Does the code compile with g++?

In order to be inter-operable, we use the STL that ships with g++. Hence if you have an older g++ version that doesn’t support C++ 11 (pre 4.8.5), then this would cause this error.

-Mat

% g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)
Copyright (C) 2015 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.

% pgc++ -V18.10 --c++11 test.cpp -c
%

Hi Mat,
My default g++ is version 7.1.0:

$which g++
/opt/gcc/7.1/bin/g++

$g++ --version
g++ (GCC) 7.1.0
Copyright (C) 2017 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.

The same code compiles fine with this g++.
However,

$pgc++ --c++11 -c -dryrun ./test.cpp
/opt/pgi/linux86-64/18.10/bin/pggpp1 ... -I/opt/pgi/linux86-64/18.10/include-gcc44 -I/usr/include/c++/4.4.7 -I/usr/include/c++/4.4.7/x86_64-redhat-linux -I/usr/include/c++/4.4.7/backward -I/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include ... --gnu_version=40407 -D__pgnu_vsn=40407 --c++11 -q -o test.il ./test.cpp

When I install or run pgc++, can I force it to use a specific version of GCC?
Thanks!

Edit: --gnu_version (Reference Manual :: PGI version 18.10 Documentation for x86 and NVIDIA Processors) is not working for me

$pgc++ --gnu_version 7.1.0 -c test.cpp 
Command-line error: invalid number: 7.1.0
1 catastrophic error detected in this compilation.
Compilation terminated.

$pgc++ --gnu_version 4.4.7 -c test.cpp 
Command-line error: invalid number: 4.4.7
1 catastrophic error detected in this compilation.
Compilation terminated.

Mat,
Your answer in an early thread worked for me:

Thank you!