From 820699b385204c74dc338d7617bc8bdea7b77c7c Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Thu, 27 Oct 2016 11:25:27 -0400 Subject: [PATCH] Fix for gcc and clang. Right now gcc throws an old ABI version of std::ios_base::failure even when the version being used is the newer ABI version of std::ios_base::failure. I have been told that this will be fixed in gcc-7. --- test/ios_state_test.cpp | 15 +++++++++++++-- test/ios_state_unit_test.cpp | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/test/ios_state_test.cpp b/test/ios_state_test.cpp index 1f7fa84..ea0701f 100644 --- a/test/ios_state_test.cpp +++ b/test/ios_state_test.cpp @@ -10,6 +10,7 @@ // 15 Jun 2003 Adjust to changes in Boost.Test (Daryle Walker) // 26 Feb 2002 Initial version (Daryle Walker) +#include #include // main, BOOST_CHECK, etc. #include // for boost::exit_success @@ -24,7 +25,9 @@ #include // for std::endl, std::ostream #include // for std::streambuf #include // for std::string - +#if defined(BOOST_GCC) +#include +#endif // Facet with the bool names spelled backwards class backward_bool_names @@ -181,11 +184,15 @@ saver_tests_1 boost::io::ios_exception_saver const ies( output ); boost::io::ios_iostate_saver const iis( output ); - output.exceptions( ios_base::eofbit ); + output.exceptions( ios_base::eofbit | ios_base::badbit ); output.setstate( ios_base::eofbit ); BOOST_ERROR( "previous line should have thrown" ); } +#if defined(BOOST_GCC) || (defined(BOOST_CLANG) && defined(BOOST_GNU_STDLIB)) + catch ( std::exception &f ) +#else catch ( ios_base::failure &f ) +#endif { err << "Got the expected I/O failure: \"" << f.what() << "\".\n"; BOOST_CHECK( output.exceptions() == ios_base::goodbit ); @@ -243,7 +250,11 @@ saver_tests_2 BOOST_ERROR( "previous line should have thrown" ); } +#if defined(BOOST_GCC) || (defined(BOOST_CLANG) && defined(BOOST_GNU_STDLIB)) + catch ( std::exception &f ) +#else catch ( ios_base::failure &f ) +#endif { err << "Got the expected I/O failure: \"" << f.what() << "\".\n"; BOOST_CHECK( output.exceptions() == ios_base::goodbit ); diff --git a/test/ios_state_unit_test.cpp b/test/ios_state_unit_test.cpp index 6a2451d..d2de756 100644 --- a/test/ios_state_unit_test.cpp +++ b/test/ios_state_unit_test.cpp @@ -9,6 +9,7 @@ // Revision History // 12 Sep 2003 Initial version (Daryle Walker) +#include #include // for boost::io::ios_flags_saver, etc. #include // for main, BOOST_CHECK, etc. @@ -19,6 +20,9 @@ #include // for std::iostream #include // for std::locale, std::numpunct #include // for std::stringstream, etc. +#if defined(BOOST_GCC) +#include +#endif // Global constants @@ -226,9 +230,14 @@ ios_exception_saver_unit_test { boost::io::ios_iostate_saver iis( ss ); + ss.exceptions( ios_base::failbit | ios_base::badbit ); char c; +#if defined(BOOST_GCC) || (defined(BOOST_CLANG) && defined(BOOST_GNU_STDLIB)) + BOOST_CHECK_THROW( ss >> c, std::exception ); +#else BOOST_CHECK_THROW( ss >> c, std::ios_base::failure ); +#endif } } @@ -575,9 +584,14 @@ ios_all_saver_unit_test { boost::io::ios_iostate_saver iis( ss ); + ss.exceptions( ios_base::failbit | ios_base::badbit ); char c; +#if defined(BOOST_GCC) || (defined(BOOST_CLANG) && defined(BOOST_GNU_STDLIB)) + BOOST_CHECK_THROW( ss >> c, std::exception ); +#else BOOST_CHECK_THROW( ss >> c, std::ios_base::failure ); +#endif } ss.tie( &clog );