Skip to content

Commit

Permalink
fix Issue 13089 - Spurious 'is not nothrow' error on static array ini…
Browse files Browse the repository at this point in the history
…tialization
  • Loading branch information
9rnsr committed Jul 11, 2014
1 parent 49f0db5 commit 60ae165
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/canthrow.c
Expand Up @@ -119,7 +119,11 @@ bool canThrow(Expression *e, FuncDeclaration *func, bool mustNotThrow)
*/
Type *t;
if (ae->type->toBasetype()->ty == Tsarray)
{
if (!ae->e2->isLvalue())
return;
t = ae->type;
}
else if (ae->e1->op == TOKslice)
t = ((SliceExp *)ae->e1)->e1->type;
else
Expand Down
24 changes: 24 additions & 0 deletions test/runnable/sdtor.d
Expand Up @@ -3268,6 +3268,29 @@ void test12686()
assert(Foo12686.count == 2);
}

/**********************************/
// 13089

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

void* p13089;

S13089[1000] foo13089() nothrow
{
typeof(return) data;
p13089 = &data;
return data;
}

void test13089() nothrow
{
immutable data = foo13089();
assert(p13089 == &data);
}

/**********************************/

int main()
Expand Down Expand Up @@ -3370,6 +3393,7 @@ int main()
test12591();
test12660();
test12686();
test13089();

printf("Success\n");
return 0;
Expand Down

0 comments on commit 60ae165

Please sign in to comment.