Bug 13089 – Spurious 'is not nothrow' error on static array initialization
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-07-10T14:17:17Z
Last change time
2017-12-18T22:58:18Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
Kenji Hara
Comments
Comment #0 by k.hara.pg — 2014-07-10T14:17:17Z
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.