id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 13430,boost::optional C++98 and C++11 compatability breaks in boost 1.66.0,nialljosullivan@…,Fernando Cacciola,"Hi, I have an application that links both C++98 and C++11 libraries, this has worked fine up to and including boost 1.65.1 The issue is caused by a shared header from the C++98 library that uses boost::optional, when compiled by the C++11 code it gets a different class layout of boost::optional to the C++98 code and this is causing binary incompatibilities and seg faults. Observed on both a Mac with clang 9.0.0 and RHEL with gcc 4.8.5. Windows does not have this issue. A simple example is a C++98 class Test98 as follows (test98.hpp) {{{ #include class Test98 { public: Test98 (boost::optional o = boost::none); private: boost::optional o_; }; }}} with implementation (test98.cpp) {{{ #include ""test98.hpp"" Test98::Test98 (boost::optional o) : o_(o) {} }}} Then a main program (main11.cpp) {{{ #include #include int main () { boost::shared_ptr t98 = boost::make_shared(); std::cout << ""OK"" << std::endl; return 0; } }}} When I compile test98.cpp as C++98 and main11.cpp as C++11, e.g. with a Makefile {{{ boost=/Users/niall/dev/boost_1_66_0 all: main11 clean: rm *.o main11 test98.o: test98.cpp g++ -c -Wall -g -O0 -I${boost} $< -o $@ main11.o: main11.cpp g++ -c -std=c++11 -g -O0 -Wall -I${boost} $< -o $@ main11: main11.o test98.o g++ $^ -o $@ }}} it causes a seg fault, in a debugger I can see the problem is the boost::optional constructor at optional.hpp:946 {{{ 945 #else -> 946 optional ( optional const& rhs ) : base( static_cast(rhs) ) {} 947 #endif }}} One might argue that it is wrong to attempt to mix 98 and 11 like this, the two preprocessor runs above are generating different versions of test98.hpp, but it works previously so is a regression issue for me. Regards, Niall.",Bugs,new,To Be Determined,optional,Boost 1.66.0,Regression,,,