[PATCH] Help compiler detect invalid code
François Dumont
frs.dumont@gmail.com
Thu Sep 19 20:28:00 GMT 2019
Hi
   I start working on making recently added constexpr tests to work in
Debug mode.
   It appears that the compiler is able to detect code mistakes pretty
well as long we don't try to hide the code intention with a defensive
approach. This is why I'd like to propose to replace '__n > 0'
conditions with '__n != 0'.
   The result is demonstrated by the constexpr_neg.cc tests. What do
you think ?
   * include/bits/stl_algobase.h (__memmove): Return _Tp*.
   (__memmove): Loop as long as __n is not 0.
   (__copy_move<>::__copy_m): Likewise.
   (__copy_move_backward<>::__copy_move_b): Likewise.
   * testsuite/25_algorithms/copy/constexpr.cc: Add check on copied
values.
   * testsuite/25_algorithms/copy_backward/constexpr.cc: Likewise.
   * testsuite/25_algorithms/copy/constexpr_neg.cc: New.
   * testsuite/25_algorithms/copy_backward/constexpr.cc: New.
   I'll submit the patch to fix Debug mode depending on the decision
for this one.
François
-------------- next part --------------
A non-text attachment was scrubbed...
Name: constexpr_algo.patch
Type: text/x-patch
Size: 8214 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20190919/4480572f/attachment.bin>
More information about the Libstdc++
mailing list