From 4feb3b1b35394d7c4d4fd89dc5b268ab390cf222 Mon Sep 17 00:00:00 2001 From: Matt Beardsley Date: Tue, 3 Sep 2024 20:59:44 -0400 Subject: [PATCH] Remove ABI-incompatible assertion code in any_view.hpp (#1816) * Remove ABI-incompatible assertion code in any_view.hpp If a provider of an any_view is built without NDEBUG defined, but a consumer is built with NDEBUG defined, the consumer will crash due to ABI-incompatibility in any_ref. Repros on clang with sanitizers, and that's an easily shareable demo: https://godbolt.org/z/Go9qxnjrM Can't get it to repro with a small example in gcc, even with sanitizers Repros in a small example on windows with msvc using same cpp/hpp files as above link - usually assertion failure in the assertion that this commit removes, sometimes Access Violation, but always crashes one way or another. No sanitizers needed to get a crash with msvc. It's just not easily shareable. --------- Co-authored-by: Matt Beardsley Co-authored-by: Eric Niebler --- include/range/v3/view/any_view.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/range/v3/view/any_view.hpp b/include/range/v3/view/any_view.hpp index 3899a2e90..71cc9907a 100644 --- a/include/range/v3/view/any_view.hpp +++ b/include/range/v3/view/any_view.hpp @@ -128,7 +128,9 @@ namespace ranges #ifndef NDEBUG , info_(&typeid(rtti_tag)) #endif - {} + { + (void)info_; // silence unused private member warning + } template T & get() const noexcept { @@ -138,9 +140,7 @@ namespace ranges private: void const volatile * obj_ = nullptr; -#ifndef NDEBUG std::type_info const * info_ = nullptr; -#endif }; template