Skip to content

Commit

Permalink
Remove ABI-incompatible assertion code in any_view.hpp (#1816)
Browse files Browse the repository at this point in the history
* 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 <mbeardsl@mathworks.com>
Co-authored-by: Eric Niebler <eniebler@nvidia.com>
  • Loading branch information
3 people committed Sep 4, 2024
1 parent fcfe828 commit 4feb3b1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/range/v3/view/any_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ namespace ranges
#ifndef NDEBUG
, info_(&typeid(rtti_tag<T>))
#endif
{}
{
(void)info_; // silence unused private member warning
}
template<typename T>
T & get() const noexcept
{
Expand All @@ -138,9 +140,7 @@ namespace ranges

private:
void const volatile * obj_ = nullptr;
#ifndef NDEBUG
std::type_info const * info_ = nullptr;
#endif
};

template<typename Base>
Expand Down

0 comments on commit 4feb3b1

Please sign in to comment.