DIP1000: Scoped Pointers (Discussion)

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 11 01:45:38 PDT 2016


On 8/11/2016 1:29 AM, John Colvin wrote:
> Can someone talk me through the lifetime algebra for the following?
>
> void foo()
> {
>     int a;
>     int** c;
>     void bar()
>     {
>         int* b = &a;  <= ok, b has a smaller lifetime than a
>         c = &b;    <= error, c has a larger lifetime than b
>     }
>     bar();
>     *c; //undefined behaviour
> }



More information about the Digitalmars-d mailing list