|
|
|
|
|
by groundzeros2015
44 days ago
|
|
I’m not a language lawyer but i think the part you are missing is about “type establishment”. (Is this a C vs C++ thing?) Malloc returns a buffer and then you cast it to the type you want. Similarly for all memory allocators. Punning the same region of char buffer as two different types is a bit different. |
|
Malloc returns memory that is uninitialized and has no type. The effective type of that memory is initialized on first use by C, whereas C++ relies on angelic nondeterminism to magically initialize the type at return type to whatever will work in the future.