Thread overview
[Issue 18756] Escaping address of temporary struct field
Apr 12, 2018
Radu Racariu
Apr 12, 2018
greenify
Apr 13, 2018
Jonathan M Davis
Apr 16, 2018
anonymous4
Apr 16, 2018
Jonathan M Davis
Aug 30, 2019
Nick Treleaven
Aug 30, 2019
Nick Treleaven
Mar 04, 2020
Walter Bright
April 12, 2018
https://issues.dlang.org/show_bug.cgi?id=18756

Radu Racariu <radu.racariu@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |safe
                 CC|                            |radu.racariu@gmail.com

--
April 12, 2018
https://issues.dlang.org/show_bug.cgi?id=18756

greenify <greeenify@gmail.com> changed:

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

--- Comment #1 from greenify <greeenify@gmail.com> ---
Taking an address is allowed in dip1000 and also @safe

I don't see any violation of safety in your example. The thing that isn't allowed is storing the address or returning it (though that is sometimes allowed when the compiler can guarantee that it will be @safe).

So AFAICT this is invalid?

--
April 13, 2018
https://issues.dlang.org/show_bug.cgi?id=18756

Jonathan M Davis <issues.dlang@jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang@jmdavisProg.co
                   |                            |m

--- Comment #2 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
Without -dip1000, & is not @safe. So, it's bug in that sense regardless. But on top of that, it's taking the address of a _temporary_. It's never @safe to take the address of a temporary and ideally, it wouldn't even be allowed in @sytem code, because it's always a bug.

--
April 16, 2018
https://issues.dlang.org/show_bug.cgi?id=18756

anonymous4 <dfj1esp02@sneakemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86                         |All
                 OS|Windows                     |All

--- Comment #3 from anonymous4 <dfj1esp02@sneakemail.com> ---
(In reply to Jonathan M Davis from comment #2)
> because it's always a bug.
It's correct when the result is passed to a function parameter.

--
April 16, 2018
https://issues.dlang.org/show_bug.cgi?id=18756

--- Comment #4 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
(In reply to anonymous4 from comment #3)
> (In reply to Jonathan M Davis from comment #2)
> > because it's always a bug.
> It's correct when the result is passed to a function parameter.

How so?

--
August 30, 2019
https://issues.dlang.org/show_bug.cgi?id=18756

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid

--- Comment #5 from Nick Treleaven <nick@geany.org> ---
Still present with DMD32 D Compiler v2.088.0-rc.1

--
August 30, 2019
https://issues.dlang.org/show_bug.cgi?id=18756

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=20183

--
March 04, 2020
https://issues.dlang.org/show_bug.cgi?id=18756

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|---                         |INVALID

--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> ---
The compiler is working as designed.

--