Skip to content

Commit

Permalink
<any>: std::any links when exceptions are disabled (microsoft#2193)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephan T. Lavavej <[email protected]>
  • Loading branch information
fsb4000 and StephanTLavavej committed Aug 13, 2022
1 parent 2b01c66 commit a80b114
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
6 changes: 3 additions & 3 deletions stl/inc/typeinfo
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ _INLINE_VAR constexpr int _Small_object_num_ptrs = 6 + 16 / sizeof(void*);

#if !_HAS_EXCEPTIONS

class _CRTIMP2_IMPORT bad_cast : public exception { // base of all bad cast exceptions
class bad_cast : public exception { // base of all bad cast exceptions
public:
bad_cast(const char* _Message = "bad cast") noexcept : exception(_Message) {}

Expand All @@ -41,7 +41,7 @@ protected:
}
};

class _CRTIMP2_IMPORT bad_typeid : public exception { // base of all bad typeid exceptions
class bad_typeid : public exception { // base of all bad typeid exceptions
public:
bad_typeid(const char* _Message = "bad typeid") noexcept : exception(_Message) {}

Expand All @@ -53,7 +53,7 @@ protected:
}
};

class _CRTIMP2_IMPORT __non_rtti_object : public bad_typeid { // report a non-RTTI object
class __non_rtti_object : public bad_typeid { // report a non-RTTI object
public:
__non_rtti_object(const char* _Message) : bad_typeid(_Message) {}
};
Expand Down
1 change: 1 addition & 0 deletions tests/std/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ tests\GH_000690_overaligned_function
tests\GH_000890_pow_template
tests\GH_000935_complex_numerical_accuracy
tests\GH_000940_missing_valarray_copy
tests\GH_000990_any_link_without_exceptions
tests\GH_001001_random_rejection_rounding
tests\GH_001010_filesystem_error_encoding
tests\GH_001017_discrete_distribution_out_of_range
Expand Down
7 changes: 7 additions & 0 deletions tests/std/tests/GH_000990_any_link_without_exceptions/env.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

RUNALL_INCLUDE ..\usual_17_matrix.lst
RUNALL_CROSSLIST
PM_CL="/D_HAS_EXCEPTIONS=0"
PM_CL="/D_HAS_EXCEPTIONS=1"
11 changes: 11 additions & 0 deletions tests/std/tests/GH_000990_any_link_without_exceptions/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <any>
#include <cassert>
using namespace std;

int main() {
// GH-990 <any>: std::any doesn't link when exceptions are disabled
assert(any_cast<int>(any{1729}) == 1729);
}

0 comments on commit a80b114

Please sign in to comment.