Compare commits

...

51 Commits

Author SHA1 Message Date
Peter Dimov
d1f3d3b349 Merge branch 'develop' into feature/constexpr 2018-01-29 14:57:30 +02:00
Peter Dimov
6ea02e2668 Reenable test_throws_usage() under UBSAN 2018-01-29 02:36:50 +02:00
Peter Dimov
0433e561b5 Change the invalid address of boost::throws() to 8 from 1, so that it's properly aligned 2018-01-29 02:29:14 +02:00
Peter Dimov
aec8d9056d Test that assigning to boost::throws() crashes 2018-01-28 17:29:13 +02:00
Peter Dimov
35e3e22c7e Add BOOST_SYSTEM_CONSTEXPR to operator bool 2018-01-22 23:39:59 +02:00
Peter Dimov
7b94454e7c Merge branch 'develop' into feature/constexpr 2018-01-22 21:13:37 +02:00
Peter Dimov
0b48bb8166 Use explicit operator bool when available 2018-01-22 21:13:02 +02:00
Peter Dimov
a413220f8d Add more constexpr tests 2018-01-22 19:43:28 +02:00
Peter Dimov
9f5272fa61 Install libstdc++-4.9 for clang++ 5.0 ubsan 2018-01-22 18:28:00 +02:00
Peter Dimov
19d5bf5f04 clang++ 3.8 and below requires a user-provided default constructor 2018-01-22 17:39:29 +02:00
Peter Dimov
9f5cbe223c Merge branch 'develop' into feature/constexpr 2018-01-22 08:07:54 +02:00
Peter Dimov
8cc57370ca Revert "Disable std_mismatch_test when UBSAN is defined"
This reverts commit 22189fce95.
2018-01-22 07:54:22 +02:00
Peter Dimov
42f2dbc32e Disable 03/11 tests when UBSAN is defined 2018-01-22 07:54:00 +02:00
Peter Dimov
a14074bafc Merge branch 'develop' into feature/constexpr 2018-01-22 07:19:19 +02:00
Peter Dimov
ca5357699a Enable stack trace on UBSAN Travis configurations 2018-01-22 07:17:56 +02:00
Peter Dimov
22189fce95 Disable std_mismatch_test when UBSAN is defined 2018-01-22 05:40:41 +02:00
Peter Dimov
0b18289a85 Avoid unused expression warning by using the expression 2018-01-22 05:21:08 +02:00
Peter Dimov
587ceaf739 Enable constexpr in header-only mode as well 2018-01-22 04:56:40 +02:00
Peter Dimov
8416ba067f Merge branch 'develop' into feature/constexpr 2018-01-22 03:20:23 +02:00
Peter Dimov
3b988e278b Use BOOST_SYMBOL_EXPORT instead of __declspec 2018-01-22 03:19:35 +02:00
Peter Dimov
6e87e44858 Add variant=debug,release to appveyor.yml 2018-01-22 02:21:53 +02:00
Peter Dimov
77817d8847 Fix MinGW link errors by properly exporting symbols 2018-01-22 02:20:01 +02:00
Peter Dimov
fe28fa163c Merge branch 'develop' into feature/constexpr 2018-01-21 22:32:19 +02:00
Peter Dimov
653f132147 Add -d0 to b2 headers in appveyor.yml 2018-01-21 22:31:37 +02:00
Peter Dimov
3ee2c53cbf Add equality tests using two libraries returning equivalent error codes, to check that the categories have sigle instances 2018-01-21 22:29:58 +02:00
Peter Dimov
61b4d8ef24 Fix variant=release link errors 2018-01-21 21:42:22 +02:00
Peter Dimov
3ba40116fe Merge branch 'develop' into feature/constexpr 2018-01-21 20:44:29 +02:00
Peter Dimov
ecb77edb81 Fix typo in test/Jamfile 2018-01-21 20:42:08 +02:00
Peter Dimov
d837670627 Merge branch 'develop' into feature/constexpr 2018-01-21 19:55:18 +02:00
Peter Dimov
8e631c9afd Add variant=debug,release to Travis 2018-01-21 18:22:49 +02:00
Peter Dimov
7f98fa58eb Refactor test/Jamfile 2018-01-21 18:21:34 +02:00
Peter Dimov
5866fbb2b2 Do not test boost::throws() under -fsanitize=undefined 2018-01-21 17:38:01 +02:00
Peter Dimov
f5f3652f30 Add -fsanitize=undefined to Travis 2018-01-20 18:54:38 +02:00
Peter Dimov
5f9b5d70d1 Add clang-3.3, 3.4 to Travis 2018-01-19 19:51:03 +02:00
Peter Dimov
f89fe0ea77 Merge branch 'develop' into feature/constexpr 2018-01-18 15:03:07 +02:00
Peter Dimov
b494f307b5 Fix g++ 4.4 again 2018-01-18 00:01:17 +02:00
Peter Dimov
344df6c0a0 Add support for g++ 4.4 to test/Jamfile 2018-01-17 19:06:44 +02:00
Peter Dimov
d2fdd3637a Add g++ 4.4, 4.6 to Travis 2018-01-16 19:11:33 +02:00
Peter Dimov
d0b3f59e63 Merge branch 'develop' into feature/constexpr 2018-01-16 16:12:18 +02:00
Peter Dimov
ef256b927b Add clang++-libc++ to Travis 2018-01-16 16:11:55 +02:00
Peter Dimov
83ddde6b78 Disable constexpr on g++ 7/8 in C++17 mode due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83835 2018-01-14 15:55:23 +02:00
Peter Dimov
fe55a4a963 Make error_category::op==, !=, < nonmembers (a non-literal class can't have constexpr members acc. to g++) 2018-01-14 08:49:25 +02:00
Peter Dimov
de5a0cf3ca Install libstdc++-4.9 for clang 4.0, 5.0 too 2018-01-14 07:56:11 +02:00
Peter Dimov
7b6dcf6ac6 Make error_code, error_condition literal if C++14 constexpr is available 2018-01-14 07:24:00 +02:00
Peter Dimov
d28c6ff128 Do not put categories in an unnamed namespace, as this is an ODR violation in header-only mode 2018-01-14 05:56:15 +02:00
Peter Dimov
f8ef12bcc4 Add before_main_test. 2018-01-14 05:29:02 +02:00
Peter Dimov
c3da8661dc Add test that checks for duplicate category instances 2018-01-14 05:10:44 +02:00
Peter Dimov
f69e195aaf Do not link to the library for the header-only tests 2018-01-14 04:56:58 +02:00
Peter Dimov
d0c6aae2b9 Merge pull request #22 from DanielaE/fix/narrowing
std::basic_string::size() may return a size_type which is wider than …
2017-12-16 18:58:38 +02:00
Daniela Engert
706659a97f std::basic_string::size() may return a size_type which is wider than an int.
Signed-off-by: Daniela Engert <dani@ngrt.de>
2017-12-16 10:40:49 +01:00
Peter Dimov
120860c397 Update Travis, Appveyor 2017-11-22 02:45:49 +02:00
15 changed files with 697 additions and 212 deletions

View File

@@ -1,4 +1,4 @@
# Copyright 2016, 2017 Peter Dimov
# Copyright 2016, 2017, 2018 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
@@ -28,6 +28,26 @@ matrix:
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
- os: linux
compiler: g++-4.4
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
addons:
apt:
packages:
- g++-4.4
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.6
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
addons:
apt:
packages:
- g++-4.6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.7
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
@@ -78,7 +98,6 @@ matrix:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
addons:
@@ -88,10 +107,36 @@ matrix:
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-7
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
- os: linux
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
apt:
packages:
- clang-3.3
- os: linux
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
apt:
packages:
- clang-3.4
- os: linux
compiler: clang++-3.5
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
@@ -157,6 +202,7 @@ matrix:
apt:
packages:
- clang-4.0
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
@@ -168,10 +214,39 @@ matrix:
apt:
packages:
- clang-5.0
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- os: linux
compiler: clang++-5.0
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-5.0
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- os: linux
compiler: clang++-libc++
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
addons:
apt:
packages:
- libc++-dev
- os: linux
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- libc++-dev
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
@@ -192,7 +267,7 @@ install:
script:
- |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- ./b2 libs/system/test toolset=$TOOLSET cxxstd=$CXXSTD
- ./b2 -j3 libs/system/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on}
notifications:
email:

View File

@@ -10,6 +10,7 @@ branches:
only:
- master
- develop
- /feature\/.*/
environment:
matrix:
@@ -21,38 +22,40 @@ environment:
TOOLSET: msvc-11.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-12.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXFLAGS: cxxflags=-std=c++03
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXFLAGS: cxxflags=-std=c++11
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
CXXFLAGS: cxxflags=-std=c++03
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
CXXFLAGS: cxxflags=-std=c++11
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXFLAGS: cxxflags=-std=c++03
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXFLAGS: cxxflags=-std=c++11
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXSTD: 03,11
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
CXXSTD: 03,11
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03,11
install:
- set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- cd ..
- git clone -b %APPVEYOR_REPO_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
- git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/build
- git submodule update --init libs/config
@@ -60,10 +63,11 @@ install:
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\system
- python tools/boostdep/depinst/depinst.py system
- cmd /c bootstrap
- b2 headers
- b2 -d0 headers
build: off
test_script:
- PATH=%ADDPATH%%PATH%
- b2 libs/system/test toolset=%TOOLSET% %CXXFLAGS%
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- b2 -j3 libs/system/test toolset=%TOOLSET% variant=debug,release %CXXSTD%

View File

@@ -35,39 +35,22 @@
//--------------------------------------------------------------------------------------//
namespace boost
{
namespace system
{
namespace
namespace system
{
// standard error categories -------------------------------------------------------//
namespace detail
{
class generic_error_category : public error_category
{
public:
generic_error_category(){}
const char * name() const BOOST_SYSTEM_NOEXCEPT;
std::string message( int ev ) const;
};
class system_error_category : public error_category
{
public:
system_error_category(){}
const char * name() const BOOST_SYSTEM_NOEXCEPT;
std::string message( int ev ) const;
error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT;
};
#ifdef BOOST_ERROR_CODE_HEADER_ONLY
# define BOOST_SYSTEM_DECL_ inline
#else
# define BOOST_SYSTEM_DECL_ BOOST_SYSTEM_DECL
#endif
// generic_error_category implementation ---------------------------------//
const char * generic_error_category::name() const BOOST_SYSTEM_NOEXCEPT
{
return "generic";
}
std::string generic_error_category::message( int ev ) const
BOOST_SYSTEM_DECL_ std::string generic_error_category::message( int ev ) const
{
using namespace boost::system::errc;
#if defined(__PGI)
@@ -160,12 +143,7 @@ namespace
}
// system_error_category implementation --------------------------------------------//
const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT
{
return "system";
}
error_condition system_error_category::default_error_condition( int ev ) const
BOOST_SYSTEM_DECL_ error_condition system_error_category::default_error_condition( int ev ) const
BOOST_SYSTEM_NOEXCEPT
{
using namespace boost::system::errc;
@@ -370,13 +348,13 @@ namespace
# if !defined( BOOST_WINDOWS_API )
std::string system_error_category::message( int ev ) const
BOOST_SYSTEM_DECL_ std::string system_error_category::message( int ev ) const
{
return generic_category().message( ev );
}
# else
std::string system_error_category::message( int ev ) const
BOOST_SYSTEM_DECL_ std::string system_error_category::message( int ev ) const
{
#if defined(UNDER_CE) || BOOST_PLAT_WINDOWS_RUNTIME || defined(BOOST_NO_ANSI_APIS)
std::wstring buf(128, wchar_t());
@@ -410,7 +388,7 @@ namespace
}
}
int num_chars = (buf.size() + 1) * 2;
int num_chars = static_cast<int>(buf.size() + 1) * 2;
boost::winapi::LPSTR_ narrow_buffer =
#if defined(__GNUC__)
@@ -455,7 +433,9 @@ namespace
}
# endif
} // unnamed namespace
#undef BOOST_SYSTEM_DECL_
} // namespace detail
# ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
@@ -466,23 +446,51 @@ namespace
// address for comparison purposes
# endif
# ifdef BOOST_ERROR_CODE_HEADER_ONLY
# define BOOST_SYSTEM_LINKAGE inline
# else
# define BOOST_SYSTEM_LINKAGE BOOST_SYSTEM_DECL
# endif
#if defined(BOOST_ERROR_CODE_HEADER_ONLY)
BOOST_SYSTEM_LINKAGE const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
{
static const system_error_category system_category_const;
return system_category_const;
}
// defined in error_code.hpp
BOOST_SYSTEM_LINKAGE const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
{
static const generic_error_category generic_category_const;
return generic_category_const;
}
#elif defined(BOOST_SYSTEM_HAS_CONSTEXPR)
namespace detail
{
BOOST_SYSTEM_REQUIRE_CONST_INIT BOOST_SYSTEM_DECL system_error_category system_category_instance;
BOOST_SYSTEM_REQUIRE_CONST_INIT BOOST_SYSTEM_DECL generic_error_category generic_category_instance;
BOOST_SYSTEM_DECL const error_category & system_category_ncx() BOOST_SYSTEM_NOEXCEPT
{
return system_category_instance;
}
BOOST_SYSTEM_DECL const error_category & generic_category_ncx() BOOST_SYSTEM_NOEXCEPT
{
return generic_category_instance;
}
} // namespace detail
#else
namespace detail
{
BOOST_SYSTEM_DECL const error_category & system_category_ncx() BOOST_SYSTEM_NOEXCEPT
{
static const detail::system_error_category system_category_instance;
return system_category_instance;
}
BOOST_SYSTEM_DECL const error_category & generic_category_ncx() BOOST_SYSTEM_NOEXCEPT
{
static const detail::generic_error_category generic_category_instance;
return generic_category_instance;
}
} // namespace detail
#endif
} // namespace system
} // namespace system
} // namespace boost

View File

@@ -2,6 +2,7 @@
// Copyright Beman Dawes 2006, 2007
// Copyright Christoper Kohlhoff 2007
// Copyright Peter Dimov 2017, 2018
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -38,6 +39,21 @@
#define BOOST_SYSTEM_NOEXCEPT BOOST_NOEXCEPT
#endif
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
# define BOOST_SYSTEM_HAS_CONSTEXPR
#endif
#if defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8) && __cplusplus >= 201700L
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83835
# undef BOOST_SYSTEM_HAS_CONSTEXPR
#endif
#if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
# define BOOST_SYSTEM_CONSTEXPR constexpr
#else
# define BOOST_SYSTEM_CONSTEXPR
#endif
namespace boost
{
namespace system
@@ -185,31 +201,6 @@ namespace boost
// --------------------------------------------------------------------------------//
class error_category;
// predefined error categories ---------------------------------------------------//
#ifdef BOOST_ERROR_CODE_HEADER_ONLY
inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT;
inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT;
#else
BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT;
BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT;
#endif
// deprecated synonyms ------------------------------------------------------------//
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
inline const error_category & get_system_category() { return system_category(); }
inline const error_category & get_generic_category() { return generic_category(); }
inline const error_category & get_posix_category() { return generic_category(); }
static const error_category & posix_category BOOST_ATTRIBUTE_UNUSED
= generic_category();
static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED
= generic_category();
static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED
= system_category();
#endif
#ifdef BOOST_MSVC
#pragma warning(push)
// 'this' : used in base member initializer list
@@ -232,7 +223,7 @@ namespace boost
public:
explicit std_category( boost::system::error_category const * pc ): pc_( pc )
BOOST_SYSTEM_CONSTEXPR explicit std_category( boost::system::error_category const * pc ): pc_( pc )
{
}
@@ -258,7 +249,7 @@ namespace boost
public:
error_category() BOOST_SYSTEM_NOEXCEPT: std_cat_( this ) {}
BOOST_SYSTEM_CONSTEXPR error_category() BOOST_SYSTEM_NOEXCEPT: std_cat_( this ) {}
operator std::error_category const & () const BOOST_SYSTEM_NOEXCEPT
{
@@ -283,7 +274,7 @@ namespace boost
public:
explicit std_category( boost::system::error_category const * pc ): pc_( pc )
BOOST_SYSTEM_CONSTEXPR explicit std_category( boost::system::error_category const * pc ): pc_( pc )
{
}
@@ -309,7 +300,7 @@ namespace boost
public:
error_category() BOOST_SYSTEM_NOEXCEPT: std_cat_( this ) {}
BOOST_SYSTEM_CONSTEXPR error_category() BOOST_SYSTEM_NOEXCEPT: std_cat_( this ) {}
#endif
@@ -325,19 +316,183 @@ namespace boost
BOOST_SYSTEM_NOEXCEPT;
inline virtual bool equivalent( const error_code & code,
int condition ) const BOOST_SYSTEM_NOEXCEPT;
bool operator==(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT
{ return this == &rhs; }
bool operator!=(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT
{ return this != &rhs; }
bool operator<( const error_category & rhs ) const BOOST_SYSTEM_NOEXCEPT
{ return std::less<const error_category*>()( this, &rhs ); }
};
BOOST_SYSTEM_CONSTEXPR inline bool operator==( const error_category & lhs,
const error_category & rhs ) BOOST_SYSTEM_NOEXCEPT
{ return &lhs == &rhs; }
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_category & lhs,
const error_category & rhs ) BOOST_SYSTEM_NOEXCEPT
{ return &lhs != &rhs; }
inline bool operator<( const error_category & lhs,
const error_category & rhs ) BOOST_SYSTEM_NOEXCEPT
{ return std::less<const error_category*>()( &lhs, &rhs ); }
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
// predefined error categories ---------------------------------------------------//
namespace detail
{
#ifdef BOOST_ERROR_CODE_HEADER_ONLY
# define BOOST_SYSTEM_DECL_
#else
# define BOOST_SYSTEM_DECL_ BOOST_SYSTEM_DECL
#endif
class generic_error_category: public error_category
{
public:
// clang++ 3.8 and below: initialization of const object
// requires a user-provided default constructor
BOOST_SYSTEM_CONSTEXPR generic_error_category() BOOST_SYSTEM_NOEXCEPT
{
}
const char * name() const BOOST_SYSTEM_NOEXCEPT
{
return "generic";
}
BOOST_SYSTEM_DECL_ std::string message( int ev ) const;
};
class system_error_category: public error_category
{
public:
BOOST_SYSTEM_CONSTEXPR system_error_category() BOOST_SYSTEM_NOEXCEPT
{
}
const char * name() const BOOST_SYSTEM_NOEXCEPT
{
return "system";
}
BOOST_SYSTEM_DECL_ std::string message( int ev ) const;
BOOST_SYSTEM_DECL_ error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT;
};
#undef BOOST_SYSTEM_DECL_
} // namespace detail
#define BOOST_SYSTEM_REQUIRE_CONST_INIT
#if defined(__has_cpp_attribute)
#if __has_cpp_attribute(clang::require_constant_initialization)
# undef BOOST_SYSTEM_REQUIRE_CONST_INIT
# define BOOST_SYSTEM_REQUIRE_CONST_INIT [[clang::require_constant_initialization]]
#endif
#endif
#if defined(BOOST_ERROR_CODE_HEADER_ONLY)
# if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
namespace detail
{
template<class T> struct cat_holder
{
static system_error_category system_category_instance;
static generic_error_category generic_category_instance;
};
template<class T> BOOST_SYSTEM_REQUIRE_CONST_INIT system_error_category cat_holder<T>::system_category_instance;
template<class T> BOOST_SYSTEM_REQUIRE_CONST_INIT generic_error_category cat_holder<T>::generic_category_instance;
} // namespace detail
constexpr const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
{
return detail::cat_holder<void>::system_category_instance;
}
constexpr const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
{
return detail::cat_holder<void>::generic_category_instance;
}
# else
inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
{
static const detail::system_error_category system_category_instance;
return system_category_instance;
}
inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
{
static const detail::generic_error_category generic_category_instance;
return generic_category_instance;
}
# endif
#elif defined(BOOST_SYSTEM_HAS_CONSTEXPR)
namespace detail
{
extern system_error_category system_category_instance;
extern generic_error_category generic_category_instance;
} // namespace detail
constexpr const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
{
return detail::system_category_instance;
}
constexpr const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
{
return detail::generic_category_instance;
}
#else
namespace detail
{
BOOST_SYSTEM_DECL const error_category & system_category_ncx() BOOST_SYSTEM_NOEXCEPT;
BOOST_SYSTEM_DECL const error_category & generic_category_ncx() BOOST_SYSTEM_NOEXCEPT;
} // namespace detail
inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
{
return detail::system_category_ncx();
}
inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
{
return detail::generic_category_ncx();
}
#endif
// deprecated synonyms ------------------------------------------------------------//
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
inline const error_category & get_system_category() { return system_category(); }
inline const error_category & get_generic_category() { return generic_category(); }
inline const error_category & get_posix_category() { return generic_category(); }
static const error_category & posix_category BOOST_ATTRIBUTE_UNUSED
= generic_category();
static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED
= generic_category();
static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED
= system_category();
#endif
// class error_condition ---------------------------------------------------------//
// error_conditions are portable, error_codes are system or library specific
@@ -347,8 +502,8 @@ namespace boost
public:
// constructors:
error_condition() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&generic_category()) {}
error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
BOOST_SYSTEM_CONSTEXPR error_condition() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&generic_category()) {}
BOOST_SYSTEM_CONSTEXPR error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
: m_val(val), m_cat(&cat) {}
template <class ErrorConditionEnum>
@@ -361,7 +516,7 @@ namespace boost
// modifiers:
void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
{
m_val = val;
m_cat = &cat;
@@ -376,34 +531,45 @@ namespace boost
return *this;
}
void clear() BOOST_SYSTEM_NOEXCEPT
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_SYSTEM_NOEXCEPT
{
m_val = 0;
m_cat = &generic_category();
}
// observers:
int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
std::string message() const { return m_cat->message(value()); }
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_SYSTEM_NOEXCEPT // true if error
{
return m_val != 0;
}
#else
typedef void (*unspecified_bool_type)();
static void unspecified_bool_true() {}
operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error
{
return m_val == 0 ? 0 : unspecified_bool_true;
}
bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
{
return m_val == 0;
}
#endif
// relationals:
// the more symmetrical non-member syntax allows enum
// conversions work for both rhs and lhs.
inline friend bool operator==( const error_condition & lhs,
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_condition & lhs,
const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT
{
return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val;
@@ -446,8 +612,8 @@ namespace boost
public:
// constructors:
error_code() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&system_category()) {}
error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
BOOST_SYSTEM_CONSTEXPR error_code() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&system_category()) {}
BOOST_SYSTEM_CONSTEXPR error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
: m_val(val), m_cat(&cat) {}
template <class ErrorCodeEnum>
@@ -459,7 +625,7 @@ namespace boost
}
// modifiers:
void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
{
m_val = val;
m_cat = &cat;
@@ -473,34 +639,45 @@ namespace boost
return *this;
}
void clear() BOOST_SYSTEM_NOEXCEPT
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_SYSTEM_NOEXCEPT
{
m_val = 0;
m_cat = &system_category();
}
// observers:
int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
error_condition default_error_condition() const BOOST_SYSTEM_NOEXCEPT
{ return m_cat->default_error_condition(value()); }
std::string message() const { return m_cat->message(value()); }
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_SYSTEM_NOEXCEPT // true if error
{
return m_val != 0;
}
#else
typedef void (*unspecified_bool_type)();
static void unspecified_bool_true() {}
operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error
{
return m_val == 0 ? 0 : unspecified_bool_true;
}
bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
{
return m_val == 0;
}
#endif
// relationals:
inline friend bool operator==( const error_code & lhs,
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_code & lhs,
const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
// the more symmetrical non-member syntax allows enum
// conversions work for both rhs and lhs.
@@ -555,10 +732,14 @@ namespace boost
inline system::error_code* throws()
{
// 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
// been added to error_code_test.cpp, and as visigoth mentioned it fails
// on clang for release builds with a return of 0 but works fine with (1).
return reinterpret_cast<system::error_code*>(1);
// is poisoned with nonzero rather than (0). A test, test_throws_usage(),
// has been added to error_code_test.cpp, and as visigoth mentioned it
// fails on clang for release builds with a return of 0 but works fine
// 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);
}
}
@@ -569,13 +750,13 @@ namespace boost
{
// non-member functions ------------------------------------------------//
inline bool operator!=( const error_code & lhs,
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_code & lhs,
const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
{
return !(lhs == rhs);
}
inline bool operator!=( const error_condition & lhs,
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_condition & lhs,
const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT
{
return !(lhs == rhs);

View File

@@ -8,6 +8,7 @@
# See library home page at http://www.boost.org/libs/system
import testing ;
import os ;
project
: requirements
@@ -21,11 +22,18 @@ project
<link>static:<define>BOOST_SYSTEM_STATIC_LINK=1
;
lib single_instance_lib1 : single_instance_1.cpp : <link>shared:<define>SINGLE_INSTANCE_DYN_LINK ;
lib single_instance_lib2 : single_instance_2.cpp : <link>shared:<define>SINGLE_INSTANCE_DYN_LINK ;
rule cxx03 ( properties * )
{
local result ;
if <toolset>gcc in $(properties) || <toolset>clang in $(properties)
if <toolset>gcc in $(properties)
{
result = <cxxflags>-std=c++98 ; # 4.4 has no 03
}
else if <toolset>clang in $(properties)
{
result = <cxxflags>-std=c++03 ;
}
@@ -41,11 +49,11 @@ project
{
local result ;
if <toolset-gcc:version>4.6 in $(properties)
if <toolset>gcc in $(properties)
{
result = <cxxflags>-std=c++0x ;
result = <cxxflags>-std=c++0x ; # 4.6 has no 11
}
else if <toolset>gcc in $(properties) || <toolset>clang in $(properties)
else if <toolset>clang in $(properties)
{
result = <cxxflags>-std=c++11 ;
}
@@ -57,73 +65,68 @@ project
return $(result) ;
}
rule system-run- ( sources + )
{
local result ;
result += [ run $(sources) : : : <link>static : $(sources[1]:B)_static ] ;
result += [ run $(sources) : : : <link>shared : $(sources[1]:B)_shared ] ;
result += [ run $(sources) : : : -<library>/boost/system//boost_system <define>BOOST_ERROR_CODE_HEADER_ONLY : $(sources[1]:B)_header ] ;
return $(result) ;
}
if [ os.environ UBSAN ]
{
rule system-run ( sources + )
{
# The 03/11 tests are ODR violations, no point running them under -fsanitize=undefined
return [ system-run- $(sources) ] ;
}
}
else
{
rule system-run ( sources + )
{
local result = [ system-run- $(sources) ] ;
# Test a source file built with -std=c++03 linked with a System library built without -std=c++03
result += [ run $(sources) : : : <link>static <conditional>@cxx03 : $(sources[1]:B)_static_03 ] ;
result += [ run $(sources) : : : <link>shared <conditional>@cxx03 : $(sources[1]:B)_shared_03 ] ;
# Test a source file built with -std=c++11 linked with a System library built without -std=c++11
result += [ run $(sources) : : : <link>static <conditional>@cxx11 : $(sources[1]:B)_static_11 ] ;
result += [ run $(sources) : : : <link>shared <conditional>@cxx11 : $(sources[1]:B)_shared_11 ] ;
return $(result) ;
}
}
test-suite "system"
: [ run error_code_test.cpp
: # command line
: # input files
: # requirements
<link>static
]
[ run error_code_test.cpp
: : : <link>shared : error_code_test_shared
]
[ run error_code_test.cpp
: : : <link>static <conditional>@cxx03 : error_code_test_03
]
[ run error_code_test.cpp
: : : <link>shared <conditional>@cxx03 : error_code_test_shared_03
]
[ run error_code_test.cpp
: : : <link>static <conditional>@cxx11 : error_code_test_11
]
[ run error_code_test.cpp
: : : <link>shared <conditional>@cxx11 : error_code_test_shared_11
]
[ run error_code_user_test.cpp
: : : <link>static
]
[ run error_code_user_test.cpp
: : : <link>shared : error_code_user_test_shared
]
[ run system_error_test.cpp
: : : <link>static
]
[ run system_error_test.cpp
: : : <link>shared : system_error_test_shared
]
: [ system-run error_code_test.cpp ]
[ system-run error_code_user_test.cpp ]
[ system-run system_error_test.cpp ]
[ run dynamic_link_test.cpp throw_test
: : : <link>shared : throw_test_shared
]
[ run initialization_test.cpp
: : : <link>shared : initialization_test_shared
[ system-run initialization_test.cpp ]
[ run header_only_test.cpp
: : : -<library>/boost/system//boost_system
]
[ run header_only_test.cpp
: : : <link>static
: : : -<library>/boost/system//boost_system <define>BOOST_NO_ANSI_APIS : header_only_test_no_ansi
]
[ run config_test.cpp
: : : <test-info>always_show_run_output
]
[ run std_interop_test.cpp
: : : <link>static
]
[ run std_interop_test.cpp
: : : <link>shared : std_interop_test_shared
]
[ run std_mismatch_test.cpp
: : : <link>static <conditional>@cxx03 : std_mismatch_test_03
]
[ run std_mismatch_test.cpp
: : : <link>shared <conditional>@cxx03 : std_mismatch_test_shared_03
]
[ run std_mismatch_test.cpp
: : : <link>static <conditional>@cxx11 : std_mismatch_test_11
]
[ run std_mismatch_test.cpp
: : : <link>shared <conditional>@cxx11 : std_mismatch_test_shared_11
]
[ run header_only_test.cpp
: : : <link>static <define>BOOST_NO_ANSI_APIS : header_only_test_no_ansi
: : : <test-info>always_show_run_output
]
[ system-run- std_interop_test.cpp ]
[ system-run std_mismatch_test.cpp ]
[ system-run single_instance_test.cpp single_instance_1.cpp single_instance_2.cpp ]
[ 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 ]
[ system-run before_main_test.cpp ]
[ run-fail throws_assign_fail.cpp ]
[ system-run- constexpr_test.cpp ]
;
# Quick (CI) test

30
test/before_main_test.cpp Normal file
View File

@@ -0,0 +1,30 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/system/error_code.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cerrno>
using namespace boost::system;
static error_code e1( 1, system_category() );
static std::string m1 = e1.message();
static error_code e2( ENOENT, generic_category() );
static std::string m2 = e2.message();
int main()
{
error_code e1_( 1, system_category() );
BOOST_TEST_EQ( e1, e1_ );
BOOST_TEST_EQ( m1, e1_.message() );
error_code e2_( ENOENT, generic_category() );
BOOST_TEST_EQ( e2, e2_ );
BOOST_TEST_EQ( m2, e2_.message() );
return boost::report_errors();
}

68
test/constexpr_test.cpp Normal file
View File

@@ -0,0 +1,68 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/system/error_code.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config/pragma_message.hpp>
#include <boost/static_assert.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#if !defined(BOOST_SYSTEM_HAS_CONSTEXPR)
BOOST_PRAGMA_MESSAGE("Skipping constexpr test, BOOST_SYSTEM_HAS_CONSTEXPR isn't defined")
int main() {}
#else
using namespace boost::system;
constexpr error_code e1( 1, system_category() );
BOOST_STATIC_ASSERT( e1.value() == 1 );
BOOST_STATIC_ASSERT( e1.category() == system_category() );
BOOST_STATIC_ASSERT( e1 );
BOOST_STATIC_ASSERT( e1 == e1 );
constexpr error_code e2( 2, generic_category() );
BOOST_STATIC_ASSERT( e2.value() == 2 );
BOOST_STATIC_ASSERT( e2.category() == generic_category() );
BOOST_STATIC_ASSERT( e2 );
BOOST_STATIC_ASSERT( e2 == e2 );
#if !BOOST_WORKAROUND(BOOST_GCC, < 80000)
BOOST_STATIC_ASSERT( e1 != e2 );
#endif
constexpr error_code e3;
BOOST_STATIC_ASSERT( e3.value() == 0 );
BOOST_STATIC_ASSERT( e3.category() == system_category() );
BOOST_STATIC_ASSERT( !e3 );
BOOST_STATIC_ASSERT( e3 == e3 );
#if !BOOST_WORKAROUND(BOOST_GCC, < 80000)
BOOST_STATIC_ASSERT( e1 != e3 );
#endif
int main()
{
error_code e1_( 1, system_category() );
BOOST_TEST_EQ( e1, e1_ );
error_code e2_( 2, generic_category() );
BOOST_TEST_EQ( e2, e2_ );
error_code e3_;
BOOST_TEST_EQ( e3, e3_ );
return boost::report_errors();
}
#endif

View File

@@ -1,4 +1,4 @@
// error_code_test.cpp -----------------------------------------------------//
// header_only_test.cpp -----------------------------------------------------//
// Copyright Beman Dawes 2007

View File

@@ -10,19 +10,19 @@
// This test verifiies that the error_category vtable does not suffer from
// order-of-initialization problems.
#include <boost/detail/lightweight_test.hpp>
#include <boost/system/error_code.hpp>
#include <boost/core/lightweight_test.hpp>
struct foo
{
foo()
{
boost::system::error_code ec;
ec == boost::system::errc::permission_denied;
BOOST_TEST_NE( ec, boost::system::errc::permission_denied );
}
} f;
int main( int, char ** )
int main()
{
return ::boost::report_errors();
return boost::report_errors();
}

View File

@@ -30,7 +30,7 @@ int main()
BOOST_TEST( bt.equivalent( ev, bn ) );
BOOST_TEST_EQ( bc, bn );
BOOST_TEST( bc == bn );
return boost::report_errors();
}

View File

@@ -0,0 +1,29 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/config.hpp>
#if defined(SINGLE_INSTANCE_DYN_LINK)
# define EXPORT BOOST_SYMBOL_EXPORT
#else
# define EXPORT
#endif
#include <boost/system/error_code.hpp>
using namespace boost::system;
namespace lib1
{
EXPORT error_code get_system_code()
{
return error_code( 0, system_category() );
}
EXPORT error_code get_generic_code()
{
return error_code( 0, generic_category() );
}
} // namespace lib1

View File

@@ -0,0 +1,29 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/config.hpp>
#if defined(SINGLE_INSTANCE_DYN_LINK)
# define EXPORT BOOST_SYMBOL_EXPORT
#else
# define EXPORT
#endif
#include <boost/system/error_code.hpp>
using namespace boost::system;
namespace lib2
{
EXPORT error_code get_system_code()
{
return error_code( 0, system_category() );
}
EXPORT error_code get_generic_code()
{
return error_code( 0, generic_category() );
}
} // namespace lib2

View File

@@ -0,0 +1,32 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/system/error_code.hpp>
#include <boost/core/lightweight_test.hpp>
using namespace boost::system;
namespace lib1
{
error_code get_system_code();
error_code get_generic_code();
} // namespace lib1
namespace lib2
{
error_code get_system_code();
error_code get_generic_code();
} // namespace lib2
int main()
{
BOOST_TEST_EQ( lib1::get_system_code(), lib2::get_system_code() );
BOOST_TEST_EQ( lib1::get_generic_code(), lib2::get_generic_code() );
return boost::report_errors();
}

View File

@@ -38,7 +38,6 @@ static void test_generic_category()
std::error_category const & st = bt;
BOOST_TEST_CSTR_EQ( bt.name(), st.name() );
BOOST_TEST_EQ( bt.name(), st.name() );
}
static void test_system_category()
@@ -47,7 +46,6 @@ static void test_system_category()
std::error_category const & st = bt;
BOOST_TEST_CSTR_EQ( bt.name(), st.name() );
BOOST_TEST_EQ( bt.name(), st.name() );
}
int main()

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() );
}