On Sat, 10 Nov 2018 16:25:40 +, Stanislav Blinov wrote:
> Yep, you just over-simplified the first case.
It is too simple to clearly illustrate why the code is invalid, but not so
simple that the compiler accepts that code.
> Consider:
>
> int* p;
> {
> int i;
> p =
> }
> *p =
On Saturday, 10 November 2018 at 06:56:29 UTC, Neia Neutuladh
wrote:
The following code doesn't work with @safe -dip1000:
int* p;
int i;
p =
i has a shorter lifetime than p, the compiler complains.
But this code does:
int i;
int* p;
p =
The compiler does this even
On Sat, 10 Nov 2018 11:47:24 +, Nicholas Wilson wrote:
> On Saturday, 10 November 2018 at 06:56:29 UTC, Neia Neutuladh wrote:
>> Is this right?
>
> Are you sure you added @safe to the second example?
> https://run.dlang.io/is/2RbOwK fails to compile.
Maybe take another look at the post
On Saturday, 10 November 2018 at 06:56:29 UTC, Neia Neutuladh
wrote:
Is this right?
Are you sure you added @safe to the second example?
https://run.dlang.io/is/2RbOwK fails to compile.
The following code doesn't work with @safe -dip1000:
int* p;
int i;
p =
i has a shorter lifetime than p, the compiler complains.
But this code does:
int i;
int* p;
p =
In both cases, p can't point to i before i exists, and p ceases to exist
when i ceases to exist.