diff --git a/sourcepawn/compiler/sc1.cpp b/sourcepawn/compiler/sc1.cpp index a4b9c279..03885ac1 100644 --- a/sourcepawn/compiler/sc1.cpp +++ b/sourcepawn/compiler/sc1.cpp @@ -2171,7 +2171,7 @@ static void declloc(int tokid) // // For now, we only implement the string literal initializer. if (type->is_new && needtoken('=')) { - if (type->isCharArray()) { + if (type->isCharArray() && !lexpeek(tNEW)) { // Error if we're assigning something other than a string literal. needtoken(tSTRING); @@ -2205,6 +2205,8 @@ static void declloc(int tokid) TRUE, FALSE, TRUE, FALSE, &type->idxtag[i], &child, 0, &val); + if (i == type->numdim - 1 && type->tag == pc_tag_string) + stradjust(sPRI); pushreg(sPRI); switch (ident) { diff --git a/sourcepawn/compiler/tests/ok-dynamic-char.sp b/sourcepawn/compiler/tests/ok-dynamic-char.sp new file mode 100644 index 00000000..88c7b281 --- /dev/null +++ b/sourcepawn/compiler/tests/ok-dynamic-char.sp @@ -0,0 +1,5 @@ + +public OnPluginStart() +{ + char[] x = new char[500]; +}