Skip to content

Commit

Permalink
fix Issue 19890 - ICE: Segmentation fault with negative array size
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed May 23, 2019
1 parent 8e364d3 commit fb7814c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/dmd/typesem.d
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,13 @@ extern(C++) Type typeSemantic(Type t, Loc loc, Scope* sc)
* when the bottom of element type is opaque.
*/
}
else if (tbn.isintegral() || tbn.isfloating() || tbn.ty == Tpointer || tbn.ty == Tarray || tbn.ty == Tsarray || tbn.ty == Taarray || (tbn.ty == Tstruct && ((cast(TypeStruct)tbn).sym.sizeok == Sizeok.done)) || tbn.ty == Tclass)
else if (tbn.isTypeBasic() ||
tbn.ty == Tpointer ||
tbn.ty == Tarray ||
tbn.ty == Tsarray ||
tbn.ty == Taarray ||
(tbn.ty == Tstruct && ((cast(TypeStruct)tbn).sym.sizeok == Sizeok.done)) ||
tbn.ty == Tclass)
{
/* Only do this for types that don't need to have semantic()
* run on them for the size, since they may be forward referenced.
Expand Down
7 changes: 7 additions & 0 deletions test/fail_compilation/fail19890a.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// PERMUTE_ARGS:
/*
---
fail_compilation/fail19890a.d(8): Error: `void[/^[0-9]+(LU)?$/]` size 1 * /^[0-9]+$/ exceeds 0x7fffffff size limit for static array
---
*/
void[] f = cast(void[-1]) "a";
7 changes: 7 additions & 0 deletions test/fail_compilation/fail19890b.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// PERMUTE_ARGS:
/*
---
fail_compilation/fail19890b.d(8): Error: `void[/^[0-9]+(LU)?$/]` size 1 * /^[0-9]+$/ exceeds 0x7fffffff size limit for static array
---
*/
void[] f = cast(void[-2]) "a";

0 comments on commit fb7814c

Please sign in to comment.