diff --git a/core/src/main/java/org/teavm/backend/c/generate/CodeGenerationVisitor.java b/core/src/main/java/org/teavm/backend/c/generate/CodeGenerationVisitor.java index da210fe33..5ea242c35 100644 --- a/core/src/main/java/org/teavm/backend/c/generate/CodeGenerationVisitor.java +++ b/core/src/main/java/org/teavm/backend/c/generate/CodeGenerationVisitor.java @@ -507,7 +507,7 @@ public class CodeGenerationVisitor implements ExprVisitor, StatementVisitor { writer.print(")"); stringTemporaries.add(tmp); } else if (isPrimitiveArray(type)) { - writer.print("ARRAY_DATA("); + writer.print("ARRAY_DATAN("); expr.getArguments().get(i).acceptVisitor(this); writer.print(", ").printStrictType(((ValueType.Array) type).getItemType()).print(")"); } else if (isPrimitiveBuffer(type)) { diff --git a/core/src/main/resources/org/teavm/backend/c/runtime.c b/core/src/main/resources/org/teavm/backend/c/runtime.c index a44e42a12..9f3321980 100644 --- a/core/src/main/resources/org/teavm/backend/c/runtime.c +++ b/core/src/main/resources/org/teavm/backend/c/runtime.c @@ -66,6 +66,7 @@ static inline int32_t compare_double(double a, double b) { #define ALIGN(addr, alignment) ((void*) (((uintptr_t) (addr) + ((alignment) - 1)) / (alignment) * (alignment))) #define ARRAY_LENGTH(array) (((JavaArray*) (array))->size) #define ARRAY_DATA(array, type) ((type*) ALIGN((((JavaArray*) (array)) + 1), sizeof(type))) +#define ARRAY_DATAN(array, type) (array != NULL ? ARRAY_DATA(array, type) : NULL) #define ARRAY_AT(array, type, index) (((type*) ARRAY_DATA(array, type))[index]) static void* throwClassCastException();