mirror of
https://github.com/corda/corda.git
synced 2025-06-17 06:38:21 +00:00
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:
@ -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;
|
||||
|
Reference in New Issue
Block a user