This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/TM4C129CNCZAD: Size of class in memory seems too large

Part Number: TM4C129CNCZAD

Tool/software: TI C/C++ Compiler

I have a class that looks like this:

template<typename T>
class ParameterCheck {
public:
  ParameterCheck(volatile T* parameter_ptr, T init_value):
    last_value_(init_value),
    parameter_ptr_(parameter_ptr) {};

  bool DidChange(void) {
    if (last_value_ != *parameter_ptr_) {
      last_value_ = *parameter_ptr_;
      return true;
    }
    return false;
  }
private:
  T last_value_;
  volatile T* parameter_ptr_;
};

In a function, I create arrays of this class like so:

  static ParameterCheck<int32_t> i32_parameters[] = {
    ParameterCheck<int32_t>(&parameter1, 0),
    ParameterCheck<int32_t>(&parameter2, 0),
    ParameterCheck<int32_t>(&parameter3, 0),
    ParameterCheck<int32_t>(&parameter4, 0),
    ParameterCheck<int32_t>(&parameter5, 0),
    ParameterCheck<int32_t>(&parameter6, 0),
  };


  static ParameterCheck<uint64_t> u64_parameters[] = {
   ParameterCheck<uint64_t>(&parameter7, 0ULL),
   ParameterCheck<uint64_t>(&parameter8, 0ULL)
  };

When I compile this and check the MAP file for the sizes of these structures, i32_parameters resolves to 48, which means each element is 8 bytes.  That's what I would expect from a class with an in32_t and a pointer on a 32-bit processor.  However when I check the size of u64_parameters, it reports 32 meaning that each element is 16 bytes.  It should be 4 + 8 = 12 bytes.  I get the same result if I make u64_parameters 3 elements instead of two.  Why does the compiler add an additional 4 bytes here?  Is there some alignment that I'm not accounting for?  I know the compiler is supposed to satisfy a memory width of 4, but 12 is a multiple of 4.  Does anyone have any insight as to why this might be happening?