Opened 15 years ago

Closed 15 years ago

#1302 closed Patches (fixed)

range test as_literal patch

Reported by: Shunsuke Sogame <pstade.mb@…> Owned by: Thorsten Ottosen
Milestone: Boost 1.35.0 Component: range
Version: Boost 1.34.1 Severity: Regression
Keywords: Cc:

Description

A patch for test/iterator_range.cpp and test/sub_range.cpp failure by missing as_literal.

Attachments (1)

add_as_literal.patch (2.9 KB ) - added by Shunsuke Sogame <pstade.mb@…> 15 years ago.
wrap string literals with as_literal

Download all attachments as: .zip

Change History (3)

by Shunsuke Sogame <pstade.mb@…>, 15 years ago

Attachment: add_as_literal.patch added

wrap string literals with as_literal

comment:1 by Markus Schöpflin, 15 years ago

This patch might fix this particular failure, but I don't think it should be applied, as it only masks the real problem.

The failure comes from the fact, that range currently is not able to correctly handle char[] types. For example:

str = "hello world";
rr  = make_iterator_range( str.begin(), str.begin() + 5 );
BOOST_CHECK( rr == "hello" );

This fails because rr (length 5) is compared to a char array (length 6), as the terminating null character is not correctly handled.

In boost/range/detail/implementation_help.hpp there is code that should deal with this, but it is commented out:

template< class T, std::size_t sz >
inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz] )
{
  /*
  typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c<
    is_same<char,T>::value || is_same<wchar_t,T>::value,
    char_or_wchar_t_array_tag, int >::type tag;

  return array_end<T,sz>( boost_range_array, tag() );
  */
  return boost_range_array + sz;
}

If I enable all the deactivated code in this file, all range tests pass for me on Tru64/CXX.

Thorsten, is there a reason that prevents you from enabling the deactivated code? If you lack the time, do you want me the commit the modified header?

comment:2 by Thorsten Ottosen, 15 years ago

Resolution: fixed
Status: newclosed

The bahavior for 1.35 makes your patch the correct code. I have applied it. Many thanks :-)

-Thorsten

Note: See TracTickets for help on using tickets.