Debug algos evolution

François Dumont frs.dumont@gmail.com
Thu Nov 14 21:03:00 GMT 2013


Hi

     Here is a proposal for an evolution of debug algos. It is far from 
being complete but I would like to know first if you find it interesting.

     The new approach is to expose real debug algos rather than to have 
debug macros in normal algos. To do so I had to introduce a dedicated 
namespace __cxx1998_a different of the one used for debug containers 
otherwise, because of ADL, the compiler do not know what version of the 
algo to use when it is called with an iterator of a debug container.

     The advantage of this approach is that:
- we can implement any debug checks without polluting normal algos
- debug algos are now aware about debug iterators and can remove debug 
layer before invoking normal algos. This will reduce perfomance hint of 
debug mode. For instance this code:

std::vector<int> v1, v2;
//....
std::copy(v1.begin(), v1.end(), v2.begin());

will continue to rely on memmove with or without debug mode.

     Note that I have also started implementing new checks to try and 
detect overlapping when invoking swap_ranges or copy or move. Paolo, you 
said that we needed to use std::less to do some comparison, is it also 
true for a random access iterator ?

     Some checks are even on only potential issues like in std::equal. 
For the moment debug mode will detect an issue in this algo only if all 
compared values are equals until we reach a past-the-end iterator. With 
this evolution we will notify an issue even if the first values are not 
equal. IMO it simply means that the code is wrong and will crash one day 
sooner or later.

What do you think about it ?

François


-------------- next part --------------
A non-text attachment was scrubbed...
Name: debug.patch
Type: text/x-patch
Size: 99411 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20131114/3711576b/attachment.bin>


More information about the Libstdc++ mailing list