sizeof(...) unexplainable large

Dear friends,

Just to say: My program is running correctly and there is no issue with RAM space or so.
I just do not understand how the compiler can reserve 28 bytes to the variable based on the UNION. I have even tested the situation by filling the memory using the "...asByte[n]". Then I have read the same memory range using "...asWord[n]" and with "...Data...". I know what is stored where, but the compiler assignes double the required memory. The upper 14 bytes are for nothing! How come?
I have tried to "solve" this "non-problem" with #pragma pack and #pragma pack(0..2) to no avail.
Does anyone have an idea. Hardware is mkr WiFi 1010 and mkr SD shield. Hence, nothing special.

Thank you for clarifying this. Mani

typedef struct {
  byte bWiFi;
  byte bWeb;
  byte bRTC;
  word wCntr;
  byte bSensor;
  word wPress;
  word wTemp;
  word wTerm;
} tsSDData;

typedef union {
  tsSDData Data;
  byte asByte [sizeof(tsSDData)];
  word asWord [sizeof(tsSDData)];
} tuSDData;

This will be twice the size of the original struct:

  word asWord [sizeof(tsSDData)];

asByte is ok, but you're allocating an array of words for asWord which has the same number of elements at two bytes each.

Since C doesn't bound check its arrays, it really doesn't matter how big they are...

typedef union {
  tsSDData Data;
  byte asByte [0];
  word asWord [0];
} tuSDData;

Thank you very much fellows!
Well spotted. Sometimes you look at the code for too long.

Best regards to all and stay healthy. Mani