PR 57779 New debug check

Paolo Carlini paolo.carlini@oracle.com
Thu Jul 11 16:43:00 GMT 2013


Hi,

On 07/11/2013 06:34 PM, Jonathan Wakely wrote:
> 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?
Looks like this function does a very tricky work! I think that at least 
we should use __addressof and std::less, std::greater, etc to compare 
pointers. In general, we should probably try to be conservative in the 
first implementation of the check, act only when we *really* know we 
have contiguous memory, not even "blocks", like for std::deque.

Paolo.




More information about the Libstdc++ mailing list