Merge branch 'develop' into feature/constexpr

This commit is contained in:
Peter Dimov
2018-01-29 14:57:30 +02:00
4 changed files with 37 additions and 14 deletions

View File

@@ -732,10 +732,14 @@ inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
inline system::error_code* throws() inline system::error_code* throws()
{ {
// See github.com/boostorg/system/pull/12 by visigoth for why the return // See github.com/boostorg/system/pull/12 by visigoth for why the return
// is poisoned with (1) rather than (0). A test, test_throws_usage(), has // is poisoned with nonzero rather than (0). A test, test_throws_usage(),
// been added to error_code_test.cpp, and as visigoth mentioned it fails // has been added to error_code_test.cpp, and as visigoth mentioned it
// on clang for release builds with a return of 0 but works fine with (1). // fails on clang for release builds with a return of 0 but works fine
return reinterpret_cast<system::error_code*>(1); // with (1).
// Since the undefined behavior sanitizer (-fsanitize=undefined) does not
// allow a reference to be formed to the unaligned address of (1), we use
// (8) instead.
return reinterpret_cast<system::error_code*>(8);
} }
} }

View File

@@ -125,6 +125,7 @@ else
[ run single_instance_test.cpp single_instance_lib1 single_instance_lib2 : : : <link>static : single_instance_lib_static ] [ run single_instance_test.cpp single_instance_lib1 single_instance_lib2 : : : <link>static : single_instance_lib_static ]
[ run single_instance_test.cpp single_instance_lib1 single_instance_lib2 : : : <link>shared : single_instance_lib_shared ] [ run single_instance_test.cpp single_instance_lib1 single_instance_lib2 : : : <link>shared : single_instance_lib_shared ]
[ system-run before_main_test.cpp ] [ system-run before_main_test.cpp ]
[ run-fail throws_assign_fail.cpp ]
[ system-run- constexpr_test.cpp ] [ system-run- constexpr_test.cpp ]
; ;

View File

@@ -22,7 +22,6 @@
#include <cstring> #include <cstring>
#include <functional> #include <functional>
#include <boost/cerrno.hpp> #include <boost/cerrno.hpp>
#include <boost/config/pragma_message.hpp>
// Although using directives are not the best programming practice, testing // Although using directives are not the best programming practice, testing
// with a boost::system using directive increases use scenario coverage. // with a boost::system using directive increases use scenario coverage.
@@ -247,17 +246,8 @@ int main( int, char ** )
BOOST_TEST( econd.message() != "" ); BOOST_TEST( econd.message() != "" );
BOOST_TEST( econd.message().substr( 0, 13) != "Unknown error" ); BOOST_TEST( econd.message().substr( 0, 13) != "Unknown error" );
#if !defined(UBSAN)
// the current implementation of boost::throws() relies on undefined behavior
test_throws_usage(); test_throws_usage();
#else
BOOST_PRAGMA_MESSAGE("Skipping test_throws_usage() due to UBSAN");
#endif
#ifdef BOOST_WINDOWS_API #ifdef BOOST_WINDOWS_API
std::cout << "Windows tests...\n"; std::cout << "Windows tests...\n";
// these tests probe the Windows errc decoder // these tests probe the Windows errc decoder

View File

@@ -0,0 +1,28 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/system/error_code.hpp>
using namespace boost::system;
static void f( error_code & ec )
{
ec = error_code();
}
#if defined(_WIN32)
# include <windows.h> // SetErrorMode
#endif
int main()
{
#if defined(_WIN32)
SetErrorMode( SetErrorMode( 0 ) | SEM_NOGPFAULTERRORBOX );
#endif
// this should crash
f( boost::throws() );
}