[Issue 16949] [Reg 2.073] confusing @safe error message for fields with unsafe destructors

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Dec 9 20:14:13 PST 2016


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

Martin Nowak <code at dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |---

--- Comment #2 from Martin Nowak <code at dawg.eu> ---
(In reply to Walter Bright from comment #1)
> Already fixed:
> 
> C:\cbx\bug>..\dmd test7 -transition=safe
> test7.d(6): Error: @safe destructor 'test7.B.~this' cannot call @system
> destructor 'test7.A.~this'

Mmh, it's still broken in master, [Reg 2.073] is the current development
version for the next release.
It got fixed on the scope branch by
https://github.com/dlang/dmd/commit/592824958312f0bf370f813631c4e6d0ff1862dc
which allowed to take the address of variables in @safe code, thereby obviously
nixing a check that prevents you from taking the address of a variable in @safe
code.

If you look at both commits

https://github.com/dlang/dmd/commit/c871b7b2efb49933f8b103b775079c8731c98fa8
https://github.com/dlang/dmd/commit/592824958312f0bf370f813631c4e6d0ff1862dc

The problematic code and it's fix sum up to:

if ((dve.e1.op == TOKthis || dve.e1.op == TOKsuper) && global.params.safe)
    checkAddressVar(cast(ThisExp)dve.e1)

checkAddressVar() {
    if (!v.canTakeAddressOf()) // this and super are never manifest variables
        error("bla");
    if (sc.func && !sc.intypeof && !v.isDataseg())
        // !global.params.safe was added in scope branch
        if (!global.params.safe && sc.func.setUnsafe())
            error("this is the diagnostic regression error");
}


If I understand this correctly the checkAddressVar call for this and super
caused the diagnostic regression and is now a noop on the scope branch.
How about we delete that part, both in master and on the scope branch?

--


More information about the Digitalmars-d-bugs mailing list