Repository navigation
Conversation
xt::apply was declared noexcept(noexcept(func(std::get<0>(s)))), which
only looks at the call on the first tuple element. Its body also holds an
XTENSOR_ASSERT on the index, which throws when XTENSOR_ENABLE_ASSERT is
defined. An out-of-range index, or a functor that throws for another
element of the tuple, therefore called std::terminate instead of
propagating the exception. GCC reports it with -Wterminate and clang with
-Wexceptions.
The specification is now detail::is_nothrow_apply_v, which checks every
call the body can make: the functor on each tuple element converted to R,
the R{} fallback, and the index assertion. The new
xt::detail::assert_can_throw constant tells whether a failing
XTENSOR_ASSERT throws. xutils.hpp now includes xexception.hpp, since it
uses XTENSOR_ASSERT and XTENSOR_THROW.
Contributor
Merging this PR will not alter performance1 warning
Comparing |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Description
xt::applyis declarednoexcept(noexcept(func(std::get<0>(s)))), which only looks at the call on the first tuple element. The body also holds anXTENSOR_ASSERTon the index. Both cases callstd::terminateinstead of propagating the exception:GCC reports the first one with
-Wterminateand clang with-Wexceptionsin the assert builds.The specification is now
detail::is_nothrow_apply_v: the functor on every element converted toR, theR{}fallback, and the index check, through a newdetail::assert_can_throwconstant.xutils.hppnow includesxexception.hpp, since it usesXTENSOR_ASSERT.utils.apply_propagates_exceptionandutils.apply_out_of_rangeterminate on master and pass with the fix. Thenoexceptcheck inutils.applynow expectsfalsein assert builds.