[Issue 13089] New: Spurious 'is not nothrow' error on static array initialization

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Jul 10 07:17:17 PDT 2014


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

          Issue ID: 13089
           Summary: Spurious 'is not nothrow' error on static array
                    initialization
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: k.hara.pg at gmail.com

This code will report following error:

struct S
{
    @disable this(this);    // non nothrow
}

void* p;

S[1000] foo() nothrow
{
    typeof(return) data;
    p = &data;
    return data;
}
void main() nothrow
{
    immutable data = foo();
    assert(p == &data);
}

-----
test.d(16): Error: 'test.S.__postblit' is not nothrow
test.d(14): Error: function 'D main' is nothrow yet may throw


But, if you comment out @disabled postblit in S, the code runs successfully and
the static array value that foo returned is not copied.

Therefore, the error "'test.S.__postblit' is not nothrow" is spurious.

--


More information about the Digitalmars-d-bugs mailing list