Skip to content

Conversation

@nsajko
Copy link
Contributor

@nsajko nsajko commented Jun 14, 2025

Other array types, like Memory and Array, support being constructed with undef.

This also means the malloc function is redundant and could be deleted if a breaking release ever happens.

Other array types, like `Memory` and `Array`, support being constructed
with `undef`.

This also means the `malloc` function is redundant and could be deleted
if a breaking release ever happens.
@LilithHafner LilithHafner changed the title feature: support undef constructors feature: make PtrArray{T}(undef, dims...) an alias for malloc(T, dims...) Jun 14, 2025
@LilithHafner
Copy link
Owner

Thanks for offering this! It is actually an intentional omission: I don't want to hide a leaky malloc call behind an innocuous front-end like PtrArray{Int}(undef, 5). As you demonstrate in the tests you wrote, this is a memory leak foot-gun because people don't expect undef initialization to leak memory (whereas I would expect folks to be vigilant for memory leaks when using malloc).

@nsajko nsajko deleted the feature_undef_construction branch June 14, 2025 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants