Bug ID: 85222
           Summary: [7/8 Regression] ABI breakage of __throw_ios_failure
                    by r244498
           Product: gcc
           Version: 7.3.1
            Status: UNCONFIRMED
          Keywords: ABI
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot
          Reporter: rguenth at gcc dot
                CC: redi at gcc dot
            Blocks: 66145
  Target Milestone: ---

A program compiled with a GCC defaulting to the old ABI
(like GCC 4.8) now fails to run with a dual-ABI libstdc++:

#include <iostream>
#include <fstream>
using namespace std;
int main ()
  std::ifstream pstats;
  pstats.exceptions(ifstream::failbit | ifstream::badbit | ifstream::eofbit);
  try {
      printf("\n Opening file : /proc/0/stat ");"/proc/0/stat");
  catch(ifstream::failure e)
      printf("\n!!Caught ifstream exception!!\n");
      if(pstats.is_open()) {
  return 0;
tmp> g++-4.8 t.C
tmp> ./a.out 

terminate called after throwing an instance of
  what():  basic_ios::clear: iostream error
Aborted (core dumped)
tmp> LD_LIBRARY_PATH=/space/rguenther/install/gcc-6.4/lib64 ./a.out 

 Opening file : /proc/0/stat 
!!Caught ifstream exception!!

This is because of the documented change of throwing the C++11 errors from
the libraries I/O routines in the attempt to fix PR66145.  This in turn
breaks any old programs trying to catch such exceptions thrown by the

__throw_ios_failure, while being exported, isn't called by the testcase
above but just by libstdc++ but the program is rightfully expecting to
be able to catch ifstream::failure.

A workaround is to use a libstdc++ built with --disable-libstdcxx-dual-abi
but that of course makes it incompatible with any programs using the new ABI.

Referenced Bugs:
[Bug 66145] [5/6/7 Regression] std::ios_base::failure objects thrown from use old ABI

Reply via email to