[BUG] Copying null String
/List
introduces bugs
#2834
Labels
bug
Something isn't working
mojo-repo
Tag all issues with this label
mojo-stdlib
Tag for issues related to standard library
[stdlib] core-library-q3-2024
Bug description
This has to do with how the default initializer creates a null pointer, but initializers with
capacity=0
will still callalloc(0)
, andList.__copyinit__()
always calls the one with capacity.This could be solved on multiple different levels:
List.__copyinit__()
and using the default initializer in that case.String
level, or use the buffers length inString.__len__()
instead of checking the state of the buffers underlying pointer. But this may not solve all the issues.alloc(0)
in the default initializer ofList
capacity=0
in theList
initializer and give a null pointer instead, but it might be nice for empty lists to have an identity/addressalloc(0)
give a null pointer, but that's probably not the bestList
gets SBO, this problem may go away as long as things are handled properlySteps to reproduce
System information
The text was updated successfully, but these errors were encountered: