[Issue 20809] return statement might access memory from destructed temporary
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Nov 18 09:52:37 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=20809
Dennis <dkorpel at live.nl> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |safe
CC| |dkorpel at live.nl
Hardware|x86_64 |All
OS|Linux |All
--- Comment #8 from Dennis <dkorpel at live.nl> ---
This is important for making Phobos's tempCString @safe:
```
// $(RED WARNING): $(RED Incorrect usage)
auto pInvalid1 = str.tempCString().ptr;
const char* pInvalid2 = str.tempCString();
// Both pointers refer to invalid memory here as
// returned values aren't assigned to a variable and
// both primary expressions are ended.
```
--
More information about the Digitalmars-d-bugs
mailing list