modify (THREAD_)RUNTIME_ARRAY definition so RUNTIME_ARRAY_BODY must be used

Previously, if you forgot to use RUNTIME_ARRAY_BODY to reference an
array declared with (THREAD_)RUNTIME_ARRAY, you wouldn't get a
compiler error until you tried to build on e.g. MSVC, where
runtime-sized stack arrays aren't supported.  This change ensures you
find out regardless of what compiler you're using, which ought to
protect us from regressions going forward.
This commit is contained in:
Joel Dice
2013-02-20 17:20:17 -07:00
parent fd047bd6e9
commit f04f444f23
5 changed files with 49 additions and 44 deletions

View File

@ -2325,19 +2325,20 @@ interpret3(Thread* t, const int base)
THREAD_RUNTIME_ARRAY(t, int32_t, counts, dimensions);
for (int i = dimensions - 1; i >= 0; --i) {
counts[i] = popInt(t);
if (UNLIKELY(counts[i] < 0)) {
RUNTIME_ARRAY_BODY(counts)[i] = popInt(t);
if (UNLIKELY(RUNTIME_ARRAY_BODY(counts)[i] < 0)) {
exception = makeThrowable
(t, Machine::NegativeArraySizeExceptionType, "%d", counts[i]);
(t, Machine::NegativeArraySizeExceptionType, "%d",
RUNTIME_ARRAY_BODY(counts)[i]);
goto throw_;
}
}
object array = makeArray(t, counts[0]);
object array = makeArray(t, RUNTIME_ARRAY_BODY(counts)[0]);
setObjectClass(t, array, class_);
PROTECT(t, array);
populateMultiArray(t, array, counts, 0, dimensions);
populateMultiArray(t, array, RUNTIME_ARRAY_BODY(counts), 0, dimensions);
pushObject(t, array);
} goto loop;