...
As a result, objects of type T
with automatic or dynamic storage duration must be explicitly initialized before having their value read as part of an expression unless T
is a class type or an array thereof or is an unsigned narrow character type. If T
is an unsigned narrow character type, it may be used to initialize an object of unsigned narrow character type, which results in both objects having an indeterminate value. This technique can be used to implement copy operations such as std::memcpy()
without triggering undefined behavior.
Additionally, memory dynamically allocated with a new
expression is default-initialized when the new-initialized is omitted. Memory allocated by the standard library function std::calloc()
is zero-initialized. Memory allocated by the standard library function std::realloc()
assumes the values of the original pointer but may not initialize the full range of memory. Memory allocated by any other means ( std::malloc()
, allocator objects, operator new()
, and so on) is assumed to be default-initialized.
...