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/MSP432P401R: Issue with struct members initialization

Part Number: MSP432P401R

Tool/software: TI C/C++ Compiler

Hello,

 

I have got a problem with initialization of struct members when coding in CCS 6.1 with TI v15.12.3.LTS compiler.

 Struct define is like this:

 struct structName1

 {

   enum member1;

   enum member2;

   union member3;

 };

 

union is define like below:

 union unionName

 {

    CPU_INT16U word[2];       

    CPU_FP32   flt;           

    CPU_INT32U u32;          

    ErrCode (*pFunc)(CPU_VOID);

    unionName() {flt = 0.0f;}

    unionName(CPU_FP32 _f) {flt = _f;}

    unionName(CPU_INT32U _u32) {u32 = _u32;}

    unionName(CPU_INT16U _w1, CPU_INT16U _w2) {word[0]=_w1; word[1]=_w2;}

    unionName(ErrCode (*_pFunc)(CPU_VOID)) {pFunc = _pFunc;}

 };

 

In a cpp file, a structName1 array is initialized like as following:

const structName1 className::arrayName[] =

 {

    {1, 0,  unionName(1,7)},

    {2, 7,  unionName(funcName1)},

    {0, 0,  unionName() } // must be last item

 };

 

 Then I compiled the whole project, and got no error or any warning concerning with this struct. Next I debugged this project on MSP432P401R with TI XDS 100V2.

 Right after the debugger stopped at main(), I checked the arrayName in Memory Watch Window.

   

  Data value "0x01" at address 0x200085A4 matches the init value, while value "0x87"  at address 0x200085AC doesn't match init value "0x02". And it is the same error that the value at 0x200085AD doesn't match 0x07.

 This issue occurs only when there is a union define in a struct. And it appears all the time except for the first menber of this kind struct array.

 

Does anyone know why it happens? Thank you very much!