Thread overview
[Issue 21035] wrong code when uses struct's methods of .init value
Jul 14, 2020
Stefan Koch
Jul 21, 2020
Stefan Koch
Jul 26, 2020
KytoDragon
Jul 31, 2020
Mathias LANG
Jul 13, 2021
kinke
Dec 17, 2022
Iain Buclaw
Apr 05, 2023
RazvanN
July 11, 2020
https://issues.dlang.org/show_bug.cgi?id=21035

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

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

--
July 14, 2020
https://issues.dlang.org/show_bug.cgi?id=21035

Stefan Koch <uplink.coder@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |uplink.coder@gmail.com

--- Comment #1 from Stefan Koch <uplink.coder@gmail.com> ---
How does the wrong-ness of this code manifest?

--
July 14, 2020
https://issues.dlang.org/show_bug.cgi?id=21035

--- Comment #2 from Илья Ярошенко <ilyayaroshenko@gmail.com> ---
(In reply to Stefan Koch from comment #1)
> How does the wrong-ness of this code manifest?

It fails to execute with exit code -11

--
July 21, 2020
https://issues.dlang.org/show_bug.cgi?id=21035

--- Comment #3 from Stefan Koch <uplink.coder@gmail.com> ---
What happens is that a `memcpy` fails which seems to be done executing `data[0
.. str.length] = str`
why that happens is still under investigation

--
July 26, 2020
https://issues.dlang.org/show_bug.cgi?id=21035

KytoDragon <kytodragon@e.mail.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kytodragon@e.mail.de

--- Comment #4 from KytoDragon <kytodragon@e.mail.de> ---
Aren't the ".init" values read only? The append tries to change the "data" member of the initializer, which results in an memory write error.

--
July 31, 2020
https://issues.dlang.org/show_bug.cgi?id=21035

--- Comment #5 from Илья Ярошенко <ilyayaroshenko@gmail.com> ---
(In reply to KytoDragon from comment #4)
> Aren't the ".init" values read only? The append tries to change the "data" member of the initializer, which results in an memory write error.

D doesn't prohibit to call methods of right hand side values.

--
July 31, 2020
https://issues.dlang.org/show_bug.cgi?id=21035

Mathias LANG <pro.mathias.lang@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
                 CC|                            |pro.mathias.lang@gmail.com

--- Comment #6 from Mathias LANG <pro.mathias.lang@gmail.com> ---
Definitely an accepts-invalid.
Trying to bind `.init` to a mutable lvalue should not be allowed.

--
July 13, 2021
https://issues.dlang.org/show_bug.cgi?id=21035

kinke <kinke@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|accepts-invalid             |backend
                 CC|                            |kinke@gmx.net

--- Comment #7 from kinke <kinke@gmx.net> ---
I don't see where this would be invalid - `CNB.init` is a new rvalue (analogous
to `CNB()`), `append` returns it as lvalue (allowed IIRC for DotIdExpressions),
and then its `data` buffer is copied to the `id` local. Works fine with LDC.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=21035

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--
April 05, 2023
https://issues.dlang.org/show_bug.cgi?id=21035

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #8 from RazvanN <razvan.nitu1305@gmail.com> ---
It seems that the inliner somehow screws up the code. Without -inline code runs successfully.

--