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
Issue when compiling with -D_GLIBCXX_DEBUG #2296
Comments
This is a problem with the usage of The comment provided with each of these lines is as follows: // using std::less_equal is counter-intuitive, but as the standard says (24.4.5):
// A sequence is sorted with respect to a comparator comp if for any iterator i pointing to the sequence and any non-negative integer n
// such that i + n is a valid iterator pointing to an element of the sequence, comp(*(i + n), *i) == false.
// Therefore less_equal is required to detect duplicates. The following minimum working example (godbolt) replicates this issue when compiled with #include <vector>
#include <functional>
auto main() -> int {
std::vector<int> v{1, 5, 9, 3, 2, 9, 7};
std::is_sorted(v.begin(), v.end(), std::less_equal<>());
return EXIT_SUCCESS;
} The provided excerpt is from cppreference, and correctly states the requirement for the Compare function. However, it is misinterpreted to require using the More specifically, the Compare function is required to implement strict weak ordering. In fact, the C++ working draft section on I believe that changing |
* Fix erroneous usage of the std::less_equal function as a Compare argument to is_sorted by replacing it with std::less. This will allow users to build and run with -D_GLIBCXX_DEBUG without causing a fatal error. * Update inline documentation to reflect change. Fixes xtensor-stack#2296
* Add test for duplicates in reduction indices. This was necessary because changing the binary predicate from <= to < when comparing axes indices no longer excludes duplicate values when passed to std::is_sorted. This allows both duplicates and unsorted axis indices to be identified and filtered appropriately. * Separate tests for sorted and duplicate indices for readability and improved clarity in exception messages. * Add unit tests to ensure all combinations of double axis indices are handled appropriately. * Update numpy documentation to reflect correct numpy axis specification syntax as a tuple instead of a list. According to the numpy documentation "If axis is a tuple of ints ...". This is important because specification of axis indices as a list yields an error. The list type has been updated to tuple for accuracy. For confirmation of this, refer to: https://numpy.org/doc/stable/reference/generated/numpy.sum.html#numpy.sum Fixes xtensor-stack#2296
This causes issues if you compile with -D_GLIBCXX_DEBUG. Underlying reason is described in xtensor-stack/xtensor#2296
This causes issues if you compile with -D_GLIBCXX_DEBUG. Underlying reason is described in xtensor-stack/xtensor#2296
If I compile xtensor with `-DCMAKE_CXX_FLAGS="-D_GLIBCXX_DEBUG" (macro described here) and try to run tests, some of them abort as such:
For reference, I'm on Ubuntu 20.04 with gcc 9.3.0.
I'm not sure if this is a bug or what. I discovered this via a user of OpenMC (which relies on xtensor), who reported this behavior.
The text was updated successfully, but these errors were encountered: