Jump to page: 1 2
Thread overview
[Issue 13390] [REG2.066] std.range.cycle ctor fails when empty input passed
[Issue 13390] std.range.cycle ctor fails when empty input passed
Aug 29, 2014
drug007
Aug 29, 2014
Kenji Hara
Aug 29, 2014
drug007
Aug 29, 2014
drug007
Oct 07, 2014
Martin Nowak
Feb 19, 2015
Ulrich Küttler
August 29, 2014
https://issues.dlang.org/show_bug.cgi?id=13390

--- Comment #1 from drug007 <drug2004@bk.ru> ---
Sorry, I used master instead of 2.066 branch, this reference should be https://github.com/D-Programming-Language/phobos/blob/2.066/std/range.d#L4289

P.S. it's strange, but I cannot fork phobos to make even simple PR

--
August 29, 2014
https://issues.dlang.org/show_bug.cgi?id=13390

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|std.range.cycle ctor fails  |[REG2.066] std.range.cycle
                   |when empty input passed     |ctor fails when empty input
                   |                            |passed

--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> ---
In Windows platform, the code will raise a runtime error "Integer Divide by Zero" with 2.066 and git-head (2.067alpha). But the issue does not occur with 2.065.

--
August 29, 2014
https://issues.dlang.org/show_bug.cgi?id=13390

--- Comment #3 from drug007 <drug2004@bk.ru> ---
Yes, this is 2.066 regression.
Is it suitable decision instead of:

        this(R input, size_t index = 0)
        {
            _original = input;
            _index = index % _original.length;
        }

use this
        this(R input, size_t index = 0)
        {
            _original = input;
            _index = (_original.length) ? index % _original.length : 0;
        }

If yes I can make PR.

--
August 29, 2014
https://issues.dlang.org/show_bug.cgi?id=13390

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx

--- Comment #4 from hsteoh@quickfur.ath.cx ---
Sounds reasonable, though I would write "(_original.length > 0) ? ..." for
clarity's sake.

--
August 29, 2014
https://issues.dlang.org/show_bug.cgi?id=13390

--- Comment #5 from drug007 <drug2004@bk.ru> ---
I agree with clarity. But I'm not sure if cycle may be empty at all, that's the question, I guess...

--
August 29, 2014
https://issues.dlang.org/show_bug.cgi?id=13390

monarchdodra@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra@gmail.com

--- Comment #6 from monarchdodra@gmail.com ---
(In reply to drug007 from comment #5)
> I agree with clarity. But I'm not sure if cycle may be empty at all, that's the question, I guess...

I believe cycle should not be passed an empty range. Or to be more precise, the underlying range may not at any point in time become empty.

The reasoning for this is that cycle is an infinite range, meaning it can be *statically* verified as being not empty.

Now, it is always incorrect for phobos to produce a crash. At the very least, an assert should be placed. Furthermore, I don't really believe that the constructor should fail. Rather, the operations pop should error out, and the operations front should index out of bounds.

And we should document the error. I'm on it.

--
October 07, 2014
https://issues.dlang.org/show_bug.cgi?id=13390

Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code@dawg.eu

--- Comment #7 from Martin Nowak <code@dawg.eu> ---
When was this bug introduced?
Any fix in sight?

--
October 07, 2014
https://issues.dlang.org/show_bug.cgi?id=13390

--- Comment #8 from hsteoh@quickfur.ath.cx ---
I'm surprised this worked in older releases. Or *appears* to work -- it's probably actually broken because cycle() returns an infinite range, but when the input is empty, it can't be an infinite range. So this is one of those places where the compile-time requirement of isInfinite breaks down.

--
October 07, 2014
https://issues.dlang.org/show_bug.cgi?id=13390

--- Comment #9 from monarchdodra@gmail.com ---
(In reply to Martin Nowak from comment #7)
> When was this bug introduced?

I don't know if it's a bug, but I think I introduced it. I don't remember the details though.

> Any fix in sight?

I remember having started a fix, and I still have the branch. I thought it would be as simple as placing an assert, but it turned out asserting in the constructor is over-eager, yet asserting in front is wasteful.

I need to review what I had written...

--
February 19, 2015
https://issues.dlang.org/show_bug.cgi?id=13390

Ulrich Küttler <kuettler@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kuettler@gmail.com

--- Comment #10 from Ulrich Küttler <kuettler@gmail.com> ---
https://github.com/D-Programming-Language/phobos/pull/3001

--
« First   ‹ Prev
1 2