__gnu_debug::__check_dereferenceable bug ?
Daniel Krügler
daniel.kruegler@gmail.com
Fri Oct 18 20:23:00 GMT 2013
2013/10/18 François Dumont <frs.dumont@gmail.com>:
> Available overloads are:
>
> template<typename _Iterator>
> inline bool
> __check_dereferenceable(_Iterator&)
> { return true; }
>
> template<typename _Tp>
> inline bool
> __check_dereferenceable(const _Tp* __ptr)
> { return __ptr; }
>
> template<typename _Iterator, typename _Sequence>
> inline bool
> __check_dereferenceable(const _Safe_iterator<_Iterator, _Sequence>& __x)
> { return __x._M_dereferenceable(); }
>
>
> I don't understand why the compiler is choosing the 1st overload when
> passing an lvalue rather than the 3rd, is it normal ?
Yes, this is normal. This is similar to the preference of a
copy-constructor-like template over the copy constructor for non-const
values such as in
struct S {
S();
template<class T>
S(T&);
} s1;
S s2(s1) // Selects the member template, not the copy constructor
> If so, it is ok to patch the library to take a const reference in the 1st overload ?
I believe so, yes.
- Daniel
More information about the Libstdc++
mailing list