Is a C-struct zero-initialized empty braces in C++?

316 Views Asked by At

If with C++17 I do a

struct tm mytm{};
int i{};

Will the variable mytm (and to be on the safe side, also i) be zero-initialized?

I am sent in circles through these pages:

And the closest thing I can find is from zero-initialization:

..., including value initialization of elements of aggregates for which no initializers are provided

The alternative (I somehow feel right about) would be default-initialization, which would mean no-initialization. But I find this too, value-initialization, meaning zeros. Confused...

(I note, that by the C struct-initialization the initializer can not be empty. So the argument "like in C" does not hold here.)

0

There are 0 best solutions below