Jump to page: 1 2
Thread overview
[Issue 19774] wrong code caused by opIndex
[Issue 19774] wrong code caused by generic variadic opIndex
Apr 05
ag0aep6g
Apr 25
Dlang Bot
Apr 26
Dlang Bot
Apr 29
Dlang Bot
March 30
https://issues.dlang.org/show_bug.cgi?id=19774

Илья Ярошенко <ilyayaroshenko@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code

--
April 05
https://issues.dlang.org/show_bug.cgi?id=19774

ag0aep6g <ag0aep6g@gmail.com> changed:

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

--- Comment #1 from ag0aep6g <ag0aep6g@gmail.com> ---
Slighlty more reduced:

----
C bar()
{
    return C(42);
}

C foo()
{
    return bar()[1];
}

struct C
{
    int x;

    ~this()
    {
        x = 0;
    }

    C opIndex(int a)
    {
        return this;
    }
}

void main()
{
    auto c = foo();
    assert(c.x == 42); /* fails; should pass */
}
----

--
April 05
https://issues.dlang.org/show_bug.cgi?id=19774

Илья Ярошенко <ilyayaroshenko@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|wrong code caused by        |wrong code caused by
                   |generic variadic opIndex    |opIndex

--
April 07
https://issues.dlang.org/show_bug.cgi?id=19774

--- Comment #2 from Илья Ярошенко <ilyayaroshenko@gmail.com> ---
Thank you, the reduced variant is much more generalised, looks more dangerous.

--
April 08
https://issues.dlang.org/show_bug.cgi?id=19774

--- Comment #3 from Илья Ярошенко <ilyayaroshenko@gmail.com> ---
Another one similar issue https://issues.dlang.org/show_bug.cgi?id=19793

--
April 08
https://issues.dlang.org/show_bug.cgi?id=19774

John Colvin <john.loughran.colvin@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |john.loughran.colvin@gmail.
                   |                            |com
           Severity|major                       |regression

--- Comment #4 from John Colvin <john.loughran.colvin@gmail.com> ---
Changed to regression because it worked up to and including 2.066.0

--
April 08
https://issues.dlang.org/show_bug.cgi?id=19774

Mihails Strasuns <mihails.strasuns@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mihails.strasuns@gmail.com

--- Comment #5 from Mihails Strasuns <mihails.strasuns@gmail.com> ---
Quick check with -vcg-ast shows that for opIndex different intermediate AST gets generated compared to regular function call:

C foo()
{
        C __dop3 = bar();
        return __dop3.opIndex(1);
}

vs

C foo()
{
        return ((C __tmpfordtor3 = bar();) , __tmpfordtor3).zzz();
}

--
April 08
https://issues.dlang.org/show_bug.cgi?id=19774

--- Comment #6 from Mihails Strasuns <mihails.strasuns@gmail.com> ---
Interesting that expanded code works fine when supplied manually.

--
April 08
https://issues.dlang.org/show_bug.cgi?id=19774

johanengelen@weka.io changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |johanengelen@weka.io

--- Comment #7 from johanengelen@weka.io ---
fyi with LDC: the bug is that `return bar()[1];` first calls the destructor on
the temporary returned by `bar()`, and _after_ that calls opIndex. Clearly the
order of those calls should be reversed.

--
April 25
https://issues.dlang.org/show_bug.cgi?id=19774

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #8 from Dlang Bot <dlang-bot@dlang.rocks> ---
@RazvanN7 created dlang/dmd pull request #9696 "Fix Issue 19774 - wrong code caused by opIndex" fixing this issue:

- Fix Issue 19774 - wrong code caused by opIndex

https://github.com/dlang/dmd/pull/9696

--
« First   ‹ Prev
1 2