Thread overview
[Issue 17885] Unable to remove a tuple from associative array.
Oct 08, 2017
ag0aep6g@gmail.com
Jul 05
Dlang Bot
Jul 05
Dlang Bot
October 08, 2017
https://issues.dlang.org/show_bug.cgi?id=17885

keepitsimplesirius@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |keepitsimplesirius@gmail.co
                   |                            |m

--
October 08, 2017
https://issues.dlang.org/show_bug.cgi?id=17885

ag0aep6g@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |ag0aep6g@gmail.com
          Component|druntime                    |dmd

--- Comment #1 from ag0aep6g@gmail.com ---
I think this is a wrong-code bug in the compiler.

For this D code:

----
struct T { ulong a, b; }
T f() { return T(); }

void main()
{
    int[T] set;
    set.remove(f());
}
----

dmd generates this machine code for _Dmain (excerpt):

----
   0x00000000000300ba <+14>:    call   0x30090 <_D4test1fFZSQk1T>
   0x00000000000300bf <+19>:    mov    QWORD PTR [rbp-0x8],rax
   0x00000000000300c3 <+23>:    lea    rdx,[rbp-0x8]
   0x00000000000300c7 <+27>:    lea    rsi,[rip+0x238f42]        # 0x269010
<_D17TypeInfo_S4test1T6__initZ>
   0x00000000000300ce <+34>:    mov    rdi,QWORD PTR [rbp-0x10]
   0x00000000000300d2 <+38>:    call   0x303c0 <_aaDelX>
----

Note that after the `f` call, only rax gets copied to the stack. But the other half of the return value is in rdx which is not being copied.

Changing component to dmd.

--
July 05
https://issues.dlang.org/show_bug.cgi?id=17885

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

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

--- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> ---
@FeepingCreature created dlang/dmd pull request #10140 "Fix issue 17885: use the correct expression's type when creating temporary for remove() call" fixing this issue:

- Fix issue 17885: use the correct expression's type when creating temporary
for remove() call

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

--
July 05
https://issues.dlang.org/show_bug.cgi?id=17885

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #10140 "Fix issue 17885: use the correct expression's type when creating temporary for remove() call" was merged into stable:

- 4b8438aeb1658c30f4b238c6c92925261ebb0531 by Mathis Beer:
  Fix issue 17885: use the correct expression's type when creating temporary
for remove() call

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

--