C++ error when installing Rstan 2.16.2

Operating System: CentOS release 6.5
Interface Version: 2.10.1
Output of writeLines(readLines(file.path(Sys.getenv(“HOME”), “.R/Makevars”))):

CXX_STD = CXX11

CXXFLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function

Output of devtools::session_info(“rstan”):

Session info ------------------------------------------------------------------
 setting  value
 version  R version 3.2.2 (2015-08-14)
 system   x86_64, linux-gnu
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 tz       EST5EDT,M3.2.0,M11.1.0
 date     2017-09-12
 
Packages ----------------------------------------------------------------------
 package      * version   date       source
 BH             1.65.0-1  2017-08-24 CRAN (R 3.2.2)
 colorspace     1.3-2     2016-12-14 CRAN (R 3.2.2)
 dichromat      2.0-0     2013-01-24 CRAN (R 3.2.2)
 digest         0.6.12    2017-01-27 CRAN (R 3.2.2)
 ggplot2        2.2.1     2016-12-30 CRAN (R 3.2.2)
 graphics     * 3.2.2     2016-06-22 local
 grDevices    * 3.2.2     2016-06-22 local
 grid           3.2.2     2016-06-22 local
 gridExtra      2.2.1     2016-02-29 CRAN (R 3.2.2)
 gtable         0.2.0     2016-02-26 CRAN (R 3.2.2)
 inline         0.3.14    2015-04-13 CRAN (R 3.2.2)
 labeling       0.3       2014-08-23 CRAN (R 3.2.2)
 lattice        0.20-35   2017-03-25 CRAN (R 3.2.2)
 lazyeval       0.2.0     2016-06-12 CRAN (R 3.2.2)
 magrittr       1.5       2014-11-22 CRAN (R 3.2.2)
 MASS           7.3-47    2017-04-21 CRAN (R 3.2.2)
 Matrix         1.2-11    2017-08-16 CRAN (R 3.2.2)
 methods      * 3.2.2     2016-06-22 local
 munsell        0.4.3     2016-02-13 CRAN (R 3.2.2)
 plyr           1.8.4     2016-06-08 CRAN (R 3.2.2)
 R6             2.2.2     2017-06-17 CRAN (R 3.2.2)
 RColorBrewer   1.1-2     2014-12-07 CRAN (R 3.2.2)
 Rcpp           0.12.12   2017-07-15 CRAN (R 3.2.2)
 RcppEigen      0.3.3.3.0 2017-05-01 CRAN (R 3.2.2)
 reshape2       1.4.2     2016-10-22 CRAN (R 3.2.2)
 rlang          0.1.2     2017-08-09 CRAN (R 3.2.2)
 rstan          2.10.1    2016-06-24 CRAN (R 3.2.2)
 scales         0.5.0     2017-08-24 CRAN (R 3.2.2)
 StanHeaders    2.10.0-2  2016-06-24 CRAN (R 3.2.2)
 stats        * 3.2.2     2016-06-22 local
 stats4         3.2.2     2016-06-22 local
 stringi        1.1.5     2017-04-07 CRAN (R 3.2.2)
 stringr        1.2.0     2017-02-18 CRAN (R 3.2.2)
 tibble         1.3.4     2017-08-22 CRAN (R 3.2.2)
 tools          3.2.2     2016-06-22 local
 utils        * 3.2.2     2016-06-22 local
 viridisLite    0.2.0     2017-03-24 CRAN (R 3.2.2)

I am trying to install Rstan 2.16.2 into R 3.2.2 and am getting some puzzling errors:

install.packages("rstan", repos = "https://cloud.r-project.org/", dependencies=TRUE)
* installing *source* package ‘rstan’ ...
** package ‘rstan’ successfully unpacked and MD5 sums checked
** libs  
g++ -I/n/sw/fasrcsw/apps/Core/R_core/3.2.2-fasrc03/lib64/R/include -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"`"/n/sw/fasrcsw/apps/Core/R_core/3.2.2-fasrc03/lib64/R/bin/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DFUSION_MAX_VECTOR_SIZE=12 -I/usr/local/include -I"/n/home10/emschwager/apps/R/Rcpp/include" -I"/n/home10/emschwager/apps/R/RcppEigen/include" -I"/n/home10/emschwager/apps/R/BH/include" -I"/n/home10/emschwager/apps/R/StanHeaders/include"   -fpic  -O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -c chains.cpp -o chains.o
g++ -I/n/sw/fasrcsw/apps/Core/R_core/3.2.2-fasrc03/lib64/R/include -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"`"/n/sw/fasrcsw/apps/Core/R_core/3.2.2-fasrc03/lib64/R/bin/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DFUSION_MAX_VECTOR_SIZE=12 -I/usr/local/include -I"/n/home10/emschwager/apps/R/Rcpp/include" -I"/n/home10/emschwager/apps/R/RcppEigen/include" -I"/n/home10/emschwager/apps/R/BH/include" -I"/n/home10/emschwager/apps/R/StanHeaders/include"   -fpic  -O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -c init.cpp -o init.o  
g++ -I/n/sw/fasrcsw/apps/Core/R_core/3.2.2-fasrc03/lib64/R/include -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"`"/n/sw/fasrcsw/apps/Core/R_core/3.2.2-fasrc03/lib64/R/bin/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DFUSION_MAX_VECTOR_SIZE=12 -I/usr/local/include -I"/n/home10/emschwager/apps/R/Rcpp/include" -I"/n/home10/emschwager/apps/R/RcppEigen/include" -I"/n/home10/emschwager/apps/R/BH/include" -I"/n/home10/emschwager/apps/R/StanHeaders/include"   -fpic  -O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -c lang__ast_def.cpp -o lang__ast_def.o  
In file included from /n/home10/emschwager/apps/R/StanHeaders/include/src/stan/lang/ast.hpp:68,  
                 from /n/home10/emschwager/apps/R/StanHeaders/include/src/stan/lang/ast_def.cpp:7,
                 from lang__ast_def.cpp:18:  
/n/home10/emschwager/apps/R/StanHeaders/include/src/stan/lang/ast/node/conditional_op.hpp:40: error: ISO C++ forbids initialization of member ‘has_var_’  
/n/home10/emschwager/apps/R/StanHeaders/include/src/stan/lang/ast/node/conditional_op.hpp:40: error: making ‘has_var_’ static  
/n/home10/emschwager/apps/R/StanHeaders/include/src/stan/lang/ast/node/conditional_op.hpp:40: error: ISO C++ forbids in-class initialization of non-const static member ‘has_var_’
make: *** [lang__ast_def.o] Error 1
ERROR: compilation failed for package ‘rstan’
* removing ‘/n/home10/emschwager/apps/R/rstan’
* restoring previous ‘/n/home10/emschwager/apps/R/rstan’

The downloaded source packages are in
        ‘/scratch/tmp/RtmpleX08c/downloaded_packages’
Warning message:
In install.packages("rstan", repos = "https://cloud.r-project.org/",  :
  installation of package ‘rstan’ had non-zero exit status

I am not sure if this is an Rcpp issue, a compiler bug, wrong flags, or something else. I am using g++ version 4.4.7. Could anyone help me figure out what is going on?

You need a later version of g++ and to enable C++11 to install 2.16.2. Although C++11 is not needed for 2.17.x, it will for 2.18.x.