This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

__gnu_debug::__check_dereferenceable bug ?


Hi

    Following test fails:

void
test01()
{
  bool test __attribute__((unused)) = true;

  std::forward_list<int> fl1 { 1, 2, 3 };

VERIFY( !__gnu_debug::__check_dereferenceable(fl1.before_begin()) ); // Ok
  auto bit = fl1.before_begin();
  VERIFY( !__gnu_debug::__check_dereferenceable(bit) ); // Ko
}

Even if it is a C++11 test, it is not a C++11 specific issue, there is the same for the C++03.

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 ? If so, it is ok to patch the library to take a const reference in the 1st overload ? Can I also do so for the __check_singular that has the same issue ?

François


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]