blob: dd4e994eae3fc8017621539f459a2b5c5264cb23 [file] [log] [blame]
Brian Silvermana6f7ce02018-07-07 15:04:00 -07001///////////////////////////////////////////////////////////////////////////////
2//
3// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
4//
5// This code is licensed under the MIT License (MIT).
6//
7// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
8// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
10// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
11// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
12// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
13// THE SOFTWARE.
14//
15///////////////////////////////////////////////////////////////////////////////
16
17#include <cstdlib> // for std::exit
18#include <gsl/gsl_util> // for narrow
19
20int narrow_no_throw()
21{
22 long long bigNumber = 0x0fffffffffffffff;
23 return gsl::narrow<int>(bigNumber);
24}
25
26void test_terminate()
27{
28 std::exit(0);
29}
30
31void setup_termination_handler()
32{
33#if defined(_MSC_VER)
34
35 auto& handler = gsl::details::get_terminate_handler();
36 handler = &test_terminate;
37
38#else
39
40 std::set_terminate(test_terminate);
41
42#endif
43}
44
45
46int main()
47{
48 setup_termination_handler();
49 narrow_no_throw();
50 return -1;
51}