[Issue 17470] [scope] this has longer lifetime than this
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Mon Jun  5 09:07:00 PDT 2017
    
    
  
https://issues.dlang.org/show_bug.cgi?id=17470
Vladimir Panteleev <thecybershadow at gmail.com> changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow at gmail.com
--- Comment #1 from Vladimir Panteleev <thecybershadow at gmail.com> ---
I think the compiler is correct in issuing the error, though the error message
might need improvement. The problem is that you are creating an internal
pointer to the struct, which is forbidden. Since structs are value types,
constructing an instance of X on the stack, then returning it, will cause the s
field to refer to invalid memory.
--
    
    
More information about the Digitalmars-d-bugs
mailing list