ericniebler / range-v3

Range library for C++14/17/20, basis for C++20's std::ranges
Other
4.05k stars 437 forks source link

Remove ABI-incompatible assertion code in any_view.hpp #1816

Open mjbeardsley opened 2 months ago

mjbeardsley commented 2 months ago

If a provider of an any_view is built without NDEBUG defined, but a consumer is built with NDEBUG defined (e.g., developing one project but using "release"/installed version of another), the consumer will crash due to ABI-incompatibility in any_ref.

Using "remove the assertion" as a discussion-starter, at least. I'd also understand an argument that some might want the ability to keep this assertion. If that's the case, could do something like what llvm does to separate ABI-breaking checks from non-ABI-breaking checks.

Or if we're good with just removing this assertion that works of course (as far as I can tell, it's the only ABI-breaking assertion in range-v3)

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.