[Issue 23472] scope(sucess) generate exception handling code.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 10 14:04:56 UTC 2022


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

--- Comment #4 from deadalnix <deadalnix at gmail.com> ---
No, that is true in general. For instance, you exemple:

char inc(string s, ref int i) {
    scope(success) i++;
    if (s == null)
        return 0;
    if (s.length > 256)
        return 1;
    return s[i];
}

Is trivially equivalent to:

char inc(string s, ref int i) {
    char ret;
    if (s == null) {
        ret = 0;
        goto Exit;
    }
    if (s.length > 256) {
        ret = 1:
        goto Exit;
    }

    ret = s[i];

Exit:
    i++;
    return ret;
}

--


More information about the Digitalmars-d-bugs mailing list