https://issues.dlang.org/show_bug.cgi?id=14696

--- Comment #4 from Steven Schveighoffer <[email protected]> ---
(In reply to Walter Bright from comment #3)
> struct S {
>     this(int i) {
>         c = 's';
>         p = &c;

This is not allowed, and I'm not sure it's a valid test case. You could fix by
doing this:

struct S
{
    this(ref char x){
        p = &x;
        *p = 's';
    }
    ~this() {
        if(p) *p = 'd';
        p = null;
    }
}

void main()
{
   char c = 'c';
   char o = 'o';
   int i = 1;
   writeln(*(i ? S(c).p : &o));
}

prints: d

--

Reply via email to