These sizes all look correct.
byte, bool and int initialize to zero, so they don't need to be explicitly stored in the resulting executable. 1000000 chars need 1000000 bytes, floats use 4 bytes each so need 4000000 bytes total and double use 8 bytes each, resulting in a total of 8000000 bytes.
The remaining ~16k bytes are just the code and metadata of the executable.
Comment #2 by raoofha — 2020-08-08T15:19:51Z
sorry to bother but how can I prevent float and double and char arrays from appearing in the output?
Comment #3 by kytodragon — 2020-08-08T15:23:15Z
You can have them be zero initialized by assigning zero to the array:
double[1000000] = 0;
Do note that this only decreases the size of the executable. Once the program is loaded into memory these array will obviously be expanded to their full size.
Comment #4 by raoofha — 2020-08-08T15:36:42Z
I know that but it doesn't work. my assumption was that when you don't define default values for variables the compiler doesn't put them in the output file. but in this case it doesn't work whether you init to zero or not.
Comment #5 by raoofha — 2020-08-08T15:40:40Z
and another issue is that I'm only defining struct S and never use it but it takes space anyway. but this is a minor issue for me.
Comment #6 by raoofha — 2020-08-11T14:18:27Z
setting variables to void avoid this problem.
but the output file size is still large I don't know why, I set all the variables to void.
Comment #7 by razvan.nitu1305 — 2022-03-25T11:21:21Z
Since D initializes all variables by default, it needs to store the initializer. Yes, void initialization is used to not store the initializer. This is all according to the spec, there is no bug here.