You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Scala, new Array[T](size) has the semantics of filling the array with 0/null. However, the generated C code generates only a call to malloc, which creates an uninitialized array. For C++, we should generate new R[size]() where R is the remapped type, which calls the default-initializer (because of '()'). To be compatible with C, perhaps we should generate something like static R defaultVal; for (size_t i = 0; i < size; ++i) a[i] = defaultValue; for the general case and memset for the array of primitives?
The text was updated successfully, but these errors were encountered:
In Scala,
new Array[T](size)
has the semantics of filling the array with0
/null
. However, the generated C code generates only a call tomalloc
, which creates an uninitialized array. For C++, we should generatenew R[size]()
whereR
is the remapped type, which calls the default-initializer (because of '()'). To be compatible with C, perhaps we should generate something likestatic R defaultVal; for (size_t i = 0; i < size; ++i) a[i] = defaultValue;
for the general case andmemset
for the array of primitives?The text was updated successfully, but these errors were encountered: