4 ms·
I don't think you can have a "fully mapped type" the way you describe it. Uninitalized memory in today's compilers do not have an observable value. https://www
by algesten 6y ago
I don't think you can have a "fully mapped type" the way you describe it. Uninitalized memory in today's compilers do not have an observable value.
https://www.ralfj.de/blog/2019/07/14/uninit.html https://www.ralfj.de/blog/2019/07/14/uninit.html
- twoodfin 6y agoThe compiler’s representation of an uninitialized lvalue might not be observable as the article describes, but an uninitialized heap allocation from the OS (i.e. malloc()) is observable by design. Of course a language and its clever implementation can make reading unintialized values from malloc()‘d objects UB with all that implies, but that’s a spec choice. So I believe you could define what’s returned by malloc() as safely castable to one or more “fully mapped types”, which would solve the problem for vectors at least of those types.
- Animats 6y agoYes, you need to be able to at least do that, for big I/O buffers and such. Those are usually raw arrays of bytes, so no problem there. The problem I was discussing is with growable arrays, where the memory underneath is partially initialized.