[Rcpp-devel] Using C++0x in g++ changes ifelse behaviour

Douglas Bates bates at stat.wisc.edu
Tue Aug 16 07:44:30 CEST 2011


On Tue, Aug 16, 2011 at 4:02 AM, Darren Cook <darren at dcook.org> wrote:
>> I just tried and could _not_ replicate it. I just uncommented my standard
>> line with the flag in ~/.R/Makevars:
>>
>> CXXFLAGS= -std=c++0x -g -O3 -Wall -pipe -pedantic -Wno-variadic-macros
>
> Thanks Dirk.
> I tried with your line and it works for me too. So I tried shortening it
> and this works:
>  CXXFLAGS= -std=c++0x -g -O3
>
> but this does not:
>  CXXFLAGS= -std=c++0x -g
>
> This also does not work:
>  CXXFLAGS= -std=c++0x -g -Wall -pipe -pedantic -Wno-variadic-macros
>
> And neither does this:
>  CXXFLAGS= -g -Wall -pipe -pedantic -Wno-variadic-macros
>
> I.e. c++0x was a red herring, and the lack of -O3 is the problem. It
> works with -O3, -O2, -O1 and -Os, but fails to work with -O0.
>
> Very curious. I considered trying each of the individual optimization
> flags [1], to narrow it down further, until I realized how many of them
> there were.
>
> Darren
>
> [1]: http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

We had an earlier instance of something like this.  The RcppArmadillo
package defines a struct containing the version information on
Armadillo.  For some reason it is not accessible and the link step
fails with -O0.  With optimization everything is fine.  Most peculiar
indeed.


More information about the Rcpp-devel mailing list