This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C51 Bug: Bad allocation array.

C51 COMPILER V7.04


Follow code genearated is bad:

code struct {
    int i;
    union {
        char a;
        int b;
    } u;
} test_array[][10] = {
    {
        {0,                                                 {0}},
    }
};

code char TESTCODE[] = {12,24,36,42};

TESTCODE has bad allocation.

WATCH window:
'test_array | C:00x6E [] ""
'TESTCODE   | C:00x6E [ ... ]

This bug removed when array with specifed size:
... test_array[1][10] ...

Parents
  • I did all right.
    Test this code in MVS.
    No warnings and true code.
    'test_array' and TESTCODE has various addresses.
    In Keil them addresses is equal.

    BUG #2: Ignoring {} in initializations.
    Follow constructions:

    code struct {
        int i;
        struct {
            char a;
            char b;
        } u;
    } test_array[2][10] = {
        {
            {0, {1}},
            {2, {3}},
        }
    };
    
    work same as:
    ...
        {
            {0, 1, 2, 3},
        }
    };
    

    result:
    {0, {1, 2}},
    {3, {??, ??}},

    Instead of:
    {0, {1, 0}},
    {2, {3, 0}},

Reply
  • I did all right.
    Test this code in MVS.
    No warnings and true code.
    'test_array' and TESTCODE has various addresses.
    In Keil them addresses is equal.

    BUG #2: Ignoring {} in initializations.
    Follow constructions:

    code struct {
        int i;
        struct {
            char a;
            char b;
        } u;
    } test_array[2][10] = {
        {
            {0, {1}},
            {2, {3}},
        }
    };
    
    work same as:
    ...
        {
            {0, 1, 2, 3},
        }
    };
    

    result:
    {0, {1, 2}},
    {3, {??, ??}},

    Instead of:
    {0, {1, 0}},
    {2, {3, 0}},

Children
No data