New antisymmetrical debug check
François Dumont
frs.dumont@gmail.com
Thu Oct 22 19:18:00 GMT 2015
Hi
I leveraged on predefined operators to inject a new debug check for
strict weak ordering operators. It checks that for a given functor f if
f(a, b) then !f(b, a). In terms of < operator: if (a < b) assert(!(b < a)).
I had to replace the generic functors like _Iter_comp_iter by more
explicit _Iter_less_iter where this check can take place. As algos can
be used with different iterator types those checks are only performed in
C++11 and after to make sure that b < a is a valid expression.
2015-10-30 François Dumont <fdumont@gcc.gnu.org>
* include/bits/predefined_ops.h
(_Iter_less_iter): Add antisymmetrical check.
(_Iter_less_val): Likewise.
(_Val_less_iter): Likewise.
(_Iter_less_iter_comp): New.
(_Iter_comp_val): Delete.
(_Iter_comp_iter): Delete.
(_Iter_equal_to_iter_comp): New..
(_Iter_equal_to_val_comp): New.
(_Iter_less_val_comp): New.
(_Val_comp_iter): Delete.
(_Val_less_iter_comp): New.
(_Iter_comp_iter): Delete.
(_Iter_equals_to_comp): New.
(__iter_less_iter): New.
(__iter_comp_val): Delete.
(__iter_less_val): New.
(__val_comp_iter): Delete.
(__val_less_iter): New.
(__iter_equal_to_val()): Delete.
(__iter_comp_val): Delete.
(__iter_equal_to_val(_Iter_equal_to_iter)): New.
(__iter_comp_iter): Delete.
(__iter_equal_to_iter): New.
(__iter_comp_val): Delete.
(__iter_equal_to_val): New.
(__iter_less_val): New.
(__val_comp_iter): Delete.
(__val_less_iter): New.
(__iter_comp_iter): Delete.
(__iter_equals_iter): New.
(__iter_comp_val): Delete.
(__iter_equals_val): New.
(__iter_comp_iter): Delete.
(__iter_equals_iter): New.
* include/bits/stl_algo.h: Adapt.
* include/bits/stl_algobase.h: Adapt.
* include/bits/stl_heap.h: Adapt.
* include/debug/formatter.h (_Debug_msg_id): Add
__msg_antisymmetrical_ordering.
* src/c++11/debug.cc (_S_debug_messages): Add
__msg_antisymmetrical_ordering message.
* testsuite/25_algorithms/lower_bound/33613.cc: Add -std=gnu++11.
* testsuite/25_algorithms/lower_bound/
invalid_strict_weak_ordering_neg.cc: New.
Tested under Linux x86_64.
Ok to commit ?
François
-------------- next part --------------
A non-text attachment was scrubbed...
Name: antisymmetrical_check.patch
Type: text/x-patch
Size: 35463 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20151022/20292e21/attachment.bin>
More information about the Libstdc++
mailing list