Boost logo

Boost :

From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2007-10-12 16:20:35


shunsuke schrieb:

> Markus Schöpflin wrote:
>>> Here is a patch.
>>> http://svn.boost.org/trac/boost/ticket/1302
>> 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.
>
> See "Warning" in http://www.boost.org/libs/range/doc/intro.html
> In Boost1.34(or below), "hello" and (char const *)"hello" is a range whose size is 5.
> In Boost1.35, "hello" is a range whose size is 6, containing the trailing null. And
> (char const *)"hello" is no longer a range.
>
> Boost1.34(or below) behavior was rejected, because it was different from
> other array types behavior.

I wasn't aware of this, thanks for the pointer. So probably the test
should be patched, and the commented out code removed.

Nevertheless I think it's problematic to introduce such a change which
makes previously valid code now invalid, especially because it still
compiles without any problems, it just changes the observable behavior.

And it doesn't fit the principle of least surprise, IMHO. The code above
just looks right, and yet it is wrong.

> BTW, see ticket: http://svn.boost.org/trac/boost/ticket/1309
> This is more important for msvc-7.1 users.
>
> If these two patches applied, I think all the regressions will pass.

Markus


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk