https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118408

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It fails if you mix old and new ABIs in a single executable. Using either ABI
consistently throughout the entire program works OK. If you mix them and use
std::regex, the linker picks either the old or new definition of
_ZNSt8__detail8_ScannerIcE14_M_scan_normalEv (and other member functions).
Objects which expect the other definition crash because  they get the wrong
one.

The stackoverflow question has an example:

// file.cc
#include <regex>
static std::regex foo("(a|b)");

// main.cc
int main() {}

// build.sh
g++ -o new.o -c file.cc
g++ -o old.o -c file.cc -D_GLIBCXX_USE_CXX11_ABI=0 
g++ -o main main.cc new.o old.o
./main

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted (core dumped)

Reply via email to