Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C arrays are not default-initialized with NewArray #88

Open
losvald opened this issue Apr 16, 2015 · 0 comments
Open

C arrays are not default-initialized with NewArray #88

losvald opened this issue Apr 16, 2015 · 0 comments
Labels

Comments

@losvald
Copy link

losvald commented Apr 16, 2015

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants