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/TMS320F28377S: .cinit seems not to be generated according to C standard

Part Number: TMS320F28377S


Tool/software: TI C/C++ Compiler

I am using C2000 compiler 18.1.7.LTS and have the following (complex) aggregate initialization:
struct can_rcv_buffer_element can_buf_tx_motor_stat = {0};
the struct definition is:
struct can_rcv_buffer_sdu
{
    uint32_t can_id;
    uint16_t data[8];
    uint16_t len;
    bool locked;
};
struct can_rcv_buffer_element
{
    struct can_rcv_buffer_sdu sdu[2];    /* double-buffer */
    uint16_t recent_page;
};
Acc. to dis2000 it creates the following .cinit entry:
DATA Section .cinit (Little Endian), 0x26 words at 0x00000000
...
0000000a   fffe    .word 0xfffe         /* length = 2 */
0000000b   0040    .word 0x0040   /* address */
0000000c   0000    .word 0x0000   /* address */
0000000d   0000    .word 0x0000   /* value */
0000000e   0000    .word 0x0000   /* value */
This makes only limited sense. The first element in the struct is 32bit, however
in my understanding, the initialization should follow C standard clauses:
10 If an object that has automatic storage duration is not initialized explicitly, its value is indeterminate.
If an object that has static storage duration is not initialized explicitly, then:
— if it has pointer type, it is initialized to a null pointer;
— if it has arithmetic type, it is initialized to (positive or unsigned) zero;
— if it is an aggregate, every member is initialized (recursively) according to these rules;
— if it is a union, the first named member is initialized (recursively) according to theserules
21 If there are fewer initializers in a brace-enclosed list than there are elements or members of an aggregate, or fewer characters in a string literal used to initialize an array of knownsize than there are elements in the array, the remainder of the aggregate shall beinitialized implicitly the same as objects that have static storage duration.
With a complete explicit initialization, compiler behaves as it should:
struct can_rcv_buffer_element can_buf_tx_motor_stat = {
.sdu[0].can_id = 0,
.sdu[0].data = {1,2,3,4,5,6,7,8},
.sdu[0].len = 0,
.sdu[0].locked = 0,
.sdu[1].can_id = 0,
.sdu[1].data = {1,2,3,4,5,6,7,8},
.sdu[1].len = 0,
.sdu[1].locked = 0,
.recent_page = 0,
};
-->
0000000a   ffe7    .word 0xffe7   /* length = 25 */
0000000b   0040    .word 0x0040
0000000c   0000    .word 0x0000
0000000d   0000    .word 0x0000
0000000e   0000    .word 0x0000
0000000f   0001    .word 0x0001
00000010   0002    .word 0x0002
00000011   0003    .word 0x0003
00000012   0004    .word 0x0004
00000013   0005    .word 0x0005
00000014   0006    .word 0x0006
00000015   0007    .word 0x0007
00000016   0008    .word 0x0008
00000017   0000    .word 0x0000
00000018   0000    .word 0x0000
00000019   0000    .word 0x0000
0000001a   0000    .word 0x0000
0000001b   0001    .word 0x0001
0000001c   0002    .word 0x0002
0000001d   0003    .word 0x0003
0000001e   0004    .word 0x0004
0000001f   0005    .word 0x0005
00000020   0006    .word 0x0006
00000021   0007    .word 0x0007
00000022   0008    .word 0x0008
00000023   0000    .word 0x0000
00000024   0000    .word 0x0000
00000025   0000    .word 0x0000