From aec8d9056db3e340009d1f19fd070d161f6f080c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 28 Jan 2018 17:29:13 +0200 Subject: [PATCH] Test that assigning to boost::throws() crashes --- test/Jamfile.v2 | 1 + test/throws_assign_fail.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 test/throws_assign_fail.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index bf90d08..55183b8 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -125,6 +125,7 @@ else [ run single_instance_test.cpp single_instance_lib1 single_instance_lib2 : : : static : single_instance_lib_static ] [ run single_instance_test.cpp single_instance_lib1 single_instance_lib2 : : : shared : single_instance_lib_shared ] [ system-run before_main_test.cpp ] + [ run-fail throws_assign_fail.cpp ] ; # Quick (CI) test diff --git a/test/throws_assign_fail.cpp b/test/throws_assign_fail.cpp new file mode 100644 index 0000000..8453577 --- /dev/null +++ b/test/throws_assign_fail.cpp @@ -0,0 +1,28 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include + +using namespace boost::system; + +static void f( error_code & ec ) +{ + ec = error_code(); +} + +#if defined(_WIN32) +# include // SetErrorMode +#endif + +int main() +{ +#if defined(_WIN32) + + SetErrorMode( SetErrorMode( 0 ) | SEM_NOGPFAULTERRORBOX ); + +#endif + + // this should crash + f( boost::throws() ); +}