PR 57779 New debug check
Jonathan Wakely
jwakely.gcc@gmail.com
Thu Jul 11 16:35:00 GMT 2013
On 10 July 2013 21:31, François Dumont wrote:
> Hi
>
> This is a proposal to add a new debug like proposed in PR 57779.
>
> I fully implemented it that is to say that I also detect when trying to
> self insert pointers to the std::vector rather than iterators.
Excellent.
> I had to introduce a __is_lvalue_reference, should I add it to
> bits/cpp_type_traits.h or is there another way to access it without the
> C++11 mode ?
No, sadly std::is_lvalue_reference cannot be used in C++03 mode.
I think cpp_type_traits.h is the best place for it.
+ // Only containers having all elements in continuous memory can have its
+ // elements passed through pointers.
Should be:
// Only containers with all elements in contiguous memory can have their
// elements passed through pointers.
In particular, it should be s/continuous/contiguous/
+ if (&(*(__it._M_get_sequence()->_M_base().end()))
Isn't this a dereference of a non-dereferenceable iterator?
+ // Simply can't say so consider it is fine.
s/consider/assume/
+ /* Checks that an iterator do not belong to the same sequence that the one of
+ * a reference iterator.
I would say:
/* Checks that iterators do not refer to the same sequence.
+ /* This overload detect when passing pointers to the contained
elements rather
+ than using iterators.
Should be "detects"
+ /* For node based container, having not random access iterators,
+ * implementation supports usage of not foreign iterator.
I'm not sure what this means! I think it should be
+ /* For node-based containers that don't have random access iterators,
+ * this implementation supports usage of non-foreign iterators.
Is that statement true? This program says no:
#include <set>
int main()
{
std::multiset<int> s{ 1, 11, 21, 31, 41 };
s.insert(s.begin(), s.end());
}
Even if it's true, would it be possible to detect that case when
_GLIBCXX_DEBUG_PEDANTIC is defined? That is supposed to disable GNU
extensions.
> * include/debug/formatter.h (_Debug_msg_id): Add
> __msg_insert_itself_range entry.
Could that be called something a bit clearer?
Maybe __msg_insert_range_from_self?
More information about the Libstdc++
mailing list