This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: __gnu_debug::__check_dereferenceable bug ?
- From: Daniel Krügler <daniel dot kruegler at gmail dot com>
- To: François Dumont <frs dot dumont at gmail dot com>
- Cc: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 18 Oct 2013 22:23:12 +0200
- Subject: Re: __gnu_debug::__check_dereferenceable bug ?
- Authentication-results: sourceware.org; auth=none
- References: <526195B4 dot 8000002 at gmail dot com>
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