[Issue 20897] -betterC generates `try`/`catch` in the AST when using struct destructors

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jun 28 12:25:41 UTC 2020


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

--- Comment #3 from kinke <kinke at gmx.net> ---
A similar example (from https://github.com/ldc-developers/ldc/issues/3479),
this time for scope(exit):

void create(uint a, uint b, string c) {}
extern(C) int main()
{
    int a = 5;
    scope(exit) a = 6;
    create(0, 1, "2");
    return 0;
}

Currently lowered to:

extern(C) int main()
{
    int a = 5;
    try
    {
        create(0u, 1u, "2");
        return 0;
    }
    finally
        a = 6;
}

Instead of having each compiler backend translate TryFinallyStatements in
betterC mode to 2 consecutive block statements, the frontend should do this.

--


More information about the Digitalmars-d-bugs mailing list