[Issue 602] Compiler allows a goto statement to skip an initalization

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 19 06:14:45 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=602



--- Comment #13 from yebblies <yebblies at gmail.com> 2013-11-20 01:14:42 EST ---
Some test cases, the second half are an enhancement.  Please feel free to add
more in the same format.

static assert(!__traits(compiles, (bool b)
{
    if (b) goto label;
    int x;
    label: {}
    assert(!x);
}));

static assert(__traits(compiles, (bool b)
{
    int x;
    if (b) goto label;
    label: {}
}));

static assert(!__traits(compiles, (bool b)
{
    if (b) goto label;
    try
    {
        int x;
    label: {}
        assert(!x);
    }
    catch
    {
    }
}));

static assert(__traits(compiles, (bool b)
{
    if (b) goto label;
    try
    {
    label: {}
        int x;
    }
    catch
    {
    }
}));

static assert(!__traits(compiles, (bool b)
{
    if (b) goto label;
    try
    {
    }
    catch
    {
        int x;
    label: {}
        assert(!x);
    }
}));

static assert(__traits(compiles, (bool b)
{
    if (b) goto label;
    try
    {
    }
    catch
    {
    label: {}
        int x;
    }
}));

static assert(__traits(compiles, (bool b)
{
    if (b) goto label;
    try
    {
    }
    catch(Exception)
    {
    label: {}
        int x;
    }
}));

static assert(!__traits(compiles, (bool b)
{
    if (b) goto label;
    try
    {
    }
    catch(Exception e)
    {
    label: {}
        assert(e);
    }
}));

static assert(!__traits(compiles, (bool b)
{
    if (b) goto label;
    struct S
    {
        int x;
    }
    with (S())
    {
    label: {}
        assert(!x);
    }
}));

check it's ok if it's not used later

static assert(__traits(compiles, (bool b)
{
    if (b) goto label;
    int x;
    label: {}
}));

static assert(__traits(compiles, (bool b)
{
    if (b) goto label;
    try
    {
        int x;
    label: {}
    }
    catch
    {
    }
}));

static assert(__traits(compiles, (bool b)
{
    if (b) goto label;
    try
    {
    }
    catch
    {
        int x;
    label: {}
    }
}));

static assert(__traits(compiles, (bool b)
{
    if (b) goto label;
    try
    {
    }
    catch(Exception e)
    {
    label: {}
    }
}));

static assert(__traits(compiles, (bool b)
{
    if (b) goto label;
    struct S
    {
        int x;
    }
    with (S())
    {
    label: {}
    }
}));

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list