missing C++11 support in PGI 16.7 ?


it looks like PGI 16.7 does not support initializer lists introduced with the C++11 standard.

#include <vector>
#include <string>
#include <iostream>

int main(){

  std::vector<std::string> string_vec = {"a string"};
  for(const auto& s : string_vec){
    std::cout << s << std::endl;

  std::vector<double> double_vec = { 3.4 };
  for(const auto& d : double_vec){
    std::cout << d << std::endl;

  return 0;

The above example compiles (and runs) fine using GCC 5.2 (g++ -std=c++11 initializer_list.cpp), however, using PGI 16.7 the compiler issues two errors:

$ pgc++ --version
pgc++ 16.7-0 64-bit target on x86-64 Linux -tp haswell
The Portland Group - PGI Compilers and Tools
Copyright (c) 2016, NVIDIA CORPORATION.  All rights reserved.
$ pgc++ --c++11 initializer_list.cpp
"initializer_list.cpp", line 7: error: no instance of constructor
          "std::vector<_Tp, _Alloc>::vector [with _Tp=std::string,
          _Alloc=std::allocator<std::string>]" matches the argument list
            argument types are: (const char [9])
    std::vector<std::string> string_vec = {"a string"};

"initializer_list.cpp", line 12: error: copy-list-initialization cannot use a
          constructor marked "explicit"
    std::vector<double> double_vec = { 3.4 };

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

When I add more items to the initializer lists the error messages change and the compiler complains about code in “/usr/include/c++/4.4.7/bits/stl_iterator_base_types.h”, which makes me wonder why it is looking in header files that seem to correspond to GCC 4.4.7.

Is my environment screwed up or is this a compiler bug or a C++11 feature not yet fully supported?

On a side note, it also seems that pgc++ 16.7 does not handle statements such as “#pragma GCC …”.
E.g. for #pragma GCC system_header I get a compile error whereas for #pragma GCC diagnostic … I just get warnings.
The boost library contains such GCC pragma statements and I basically have to edit all boost header files containing such statements if I want my program to use boost. It is not a showstopper, but kind of inconvenient if the production environment is based on GCC and would not need any modifications of the boost library.


The problem is the missing C++11 support in g++ 4.4.7. You need to be
at least g++ 4.8.3 to have C++11 support. We need the correct g++ headers
and runtime libs to support this capability in pgc++.


Hi Dave,

I am working on a RHEL 6.6 system, which uses gcc 4.4.7 as system compiler, but I do have more recent gcc versions available on the filesystem. Actually, all the libraries my program is linked against haven been compiled with gcc 5.2.

Is there a way to point pgc++ to one of the more recent versions of gcc, I guess ideally to 5.2, available on my system. For system headers is it enough to specify -I<path to include dir of gcc 5.2 installation>? I probably need to do something similar for the linking stage so that the right libraries are selected, i.e. can I overwrite the defaults of pgc++?


Unfortunately, gcc 5.2 pgc++ is not supported yet. We should support it
with 16.10, with front end changes for C++14 as well as C++11.

Try g++ 4.8.3 or 4.9.2.


We tried to reinstall PGI compiler with gcc 5.2 (before I read your response) in the PATH variable before any other gcc version, but when I run pgc++ -drystdinc I still get the following:

 pgc++ -drystdinc
/opt/pgi/linux86-64/16.7/include-gcc44 /opt/pgi/linux86-64/16.7/include /usr/include/c++/4.4.7 /usr/include/c++/4.4.7/x86_64-redhat-linux /usr/include/c++/4.4.7/backward /usr/lib/gcc/x86_64-redhat-linux/4.4.7/include /usr/include:

So it seems that this doesn’t do the trick. Actually, the install_env script seems to reset the PATH variable right at the beginning to /usr/bin/:/bin/:/sbin:$PATH. Does this mean I need to upgrade the OS version of RHEL so that pgc++ can grab a c++11 compliant system compiler or it just fell back to the system compiler because (as you mentioned) gcc 5.2 is not yet supported. Please advise what I need to do to install a c++11 compliant version of pgc++.

Let’s say I have managed to install pgc++ with g++ 4.8.3 or 4.9.2. Will I be able to link against libraries that have been built with gcc 5.2, 5.1, or 5.0?


Can you guarantee that objects compiled with gcc 5.2 will always link properly and completely
using gcc 4.8.3? Probably not.

Linking 4.8.3 objects using gcc 5.2 should be okay.


OK, I got that part, but I still don’t know how to install PGI compiler with a gcc version other than the system gcc compiler version or whether that’s even possible. Or do I need to upgrade my RHEL version so that I have a more recent gcc version as system compiler.


The install process makes decisions by what it finds in your $path.

So if
% gcc --version

returns 4.9.2, and

% gcc -o hello hello.c -v
creates a successful executable.

Then installing the PGI compilers will create a localrc file based on
gcc 4.9.2.

So make 4.9.2 the default compiler, and it will be used during the PGI

Hi Dave,

both my IT support and myself (in my home directory) have followed your instructions, i.e. gcc 4.9.2 is in the PATH and gcc --version confirms it, but running pgc++ -drystdinc allows points to gcc 4.4.7 instead of 4.9.2, i.e the output looks like:

/opt/pgi/linux86-64/16.7/include-gcc44 /opt/pgi/linux86-64/16.7/include /usr/include/c++/4.4.7 /usr/include/c++/4.4.7/x86_64-redhat-linux /usr/include/c++/4.4.7/backward /usr/lib/gcc/x86_64-redhat-linux/4.4.7/include /usr/include:

So something does not seem to be working. Have you tried to do this with 16.7 at your end? As I mentioned in an earlier post, looking at the install script the following is done at the very beginning:

umask 022

So it seems whatever PATH I set, the installer will always find /usr/bin/gcc first, which is not the gcc I want. I could try to comment out the line where the PATH is changed, but I am wondering what side effects this could have if I start messing around with the install script.


Send the output dialogs of

gcc -m64 -v -o hello_64_gcc hello.c

using the 4.4.7 and the 4.9.2 compilers, and the localrc file you created
with the PGI installation, to trs@pgroup.com .

Also send the output of

% which ld
% which as

when you are using the 4.9.2 gcc compilers. I want to make sure
you had the correct ones in your PATH.

I will manually edit the localrc to reflect the 4.9.2 differences.