Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<any>: Skip the contents when static RTTI is disabled #3115

Merged
merged 7 commits into from
Sep 22, 2022
10 changes: 4 additions & 6 deletions stl/inc/any
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@

#if !_HAS_CXX17
_EMIT_STL_WARNING(STL4038, "The contents of <any> are available only with C++17 or later.");
#else // ^^^ !_HAS_CXX17 / _HAS_CXX17 vvv
#elif !_HAS_STATIC_RTTI // ^^^ !_HAS_CXX17 / _HAS_CXX17 vvv
_EMIT_STL_WARNING(STL4040, "The contents of <any> require static RTTI.");
#else // ^^^ !_HAS_STATIC_RTTI / _HAS_STATIC_RTTI vvv
#include <initializer_list>
#include <type_traits>
#include <typeinfo>
#include <utility>
#include <xmemory>

#if !_HAS_STATIC_RTTI
#error class any requires static RTTI.
#endif // _HAS_STATIC_RTTI

#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
Expand Down Expand Up @@ -444,7 +442,7 @@ _STD_END
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // _HAS_CXX17
#endif // ^^^ _HAS_STATIC_RTTI ^^^

#endif // _STL_COMPILER_PREPROCESSOR
#endif // _ANY_
4 changes: 3 additions & 1 deletion stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,9 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect

// STL4039 is used to warn that "The contents of <coroutine> are not available with /await."

// next warning number: STL4040
// STL4040 is used to warn that "The contents of <any> require static RTTI."

// next warning number: STL4041

// next error number: STL1006

Expand Down
4 changes: 4 additions & 0 deletions tests/std/tests/VSO_0000000_has_static_rtti/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include <typeinfo>
#include <utility>

#if _HAS_CXX17
#include <any>
#endif // _HAS_CXX17

using namespace std;

#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
Expand Down