]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Skip redundant assertions in std::array equality [PR106212]
authorJonathan Wakely <jwakely@redhat.com>
Mon, 9 Dec 2024 17:35:24 +0000 (17:35 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 11 Dec 2024 21:50:53 +0000 (21:50 +0000)
commit3aeb2edee2f9fc39ab77c7e020f09d7204b167ac
treeabadc7e347c3644a582b6151e7e4d6572628cd5a
parente95bda027e0b81922c1bf44770674190bdf787e8
libstdc++: Skip redundant assertions in std::array equality [PR106212]

As PR c++/106212 shows, the Debug Mode checks cause a compilation error
for equality comparisons involving std::array prvalues in constant
expressions. Those Debug Mode checks are redundant when
comparing two std::array objects, because we already know we have a
valid range. We can also avoid the unnecessary step of using
std::__niter_base to do __normal_iterator unwrapping, which isn't needed
because our std::array iterators are just pointers. Using
std::__equal_aux1 instead of std::equal avoids the redundant checks in
std::equal and std::__equal_aux.

libstdc++-v3/ChangeLog:

PR libstdc++/106212
* include/std/array (operator==): Use std::__equal_aux1 instead
of std::equal.
* testsuite/23_containers/array/comparison_operators/106212.cc:
New test.
libstdc++-v3/include/std/array
libstdc++-v3/testsuite/23_containers/array/comparison_operators/106212.cc [new file with mode: 0644]