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] ...
Seems like a nice short test case. I'd suggetst that you make it into a uV2 project, zip it up, and email it to the tech support address.
I don't have K&R to hand, and I forget the rules about which dimension you are allowed to leave unspecified in multi-dimension definition. I guess you have the wrong one?
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}}, } };
... { {0, 1, 2, 3}, } };
There were a few weird initialization problems in 7.03 or 7.04 that had to do with implicit type casting. These have been corrected. you may want to download the latest update (7.06a). Jon
The example posted doesn't do anything with either of those variables. In that case there's nothing particularly wrong with the compiler overlaying the two. Make sure your actual test code not only defines, but also uses those objects.