www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13089] New: Spurious 'is not nothrow' error on static array

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 puremagic.com
          Reporter: k.hara.pg 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.

--
Jul 10 2014