digitalmars.D - Bug in std.range.retro?
- Sam Hu (11/11) Jun 22 2009 Originally I posted in learn:
- Daniel Keep (5/20) Jun 22 2009 Well r[0] would translate to r.opIndex(0) which means it will return
Originally I posted in learn:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=16913
Move here to double confirm whether it is a bug:
static if (isRandomAccessRange!(R) && hasLength!(R))
ref ElementType!(R) opIndex(uint n)
{
return _input[_input.length - n + 1];
}
Shouldn't it be _input.length-(n+1) ?
Regards,
Sam
Jun 22 2009
Sam Hu wrote:
Originally I posted in learn:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=16913
Move here to double confirm whether it is a bug:
static if (isRandomAccessRange!(R) && hasLength!(R))
ref ElementType!(R) opIndex(uint n)
{
return _input[_input.length - n + 1];
}
Shouldn't it be _input.length-(n+1) ?
Regards,
Sam
Well r[0] would translate to r.opIndex(0) which means it will return
r._input[r._input.length - 0 + 1] = r._input[r._input.length + 1] which
is outside the array bounds.
So yes, it's a bug.
Jun 22 2009








Daniel Keep <daniel.keep.lists gmail.com>