Sizeof calculate a wrong arraysize for a "open" array.
The version is SDCC Version 2.3.2
This sample shold return 6 , not 4.
----------------------------
volatile unsigned char test;
code unsigned char buf[][2]={{0,1},{2,3},{4,5}};
main()
{
test=sizeof(buf);
}
----------------------------
0038 75 08 04 122 mov _test,#0x04
003B 123 00101$:
003B 22 124 ret
125 .area CSEG
(CODE)
003C 126 _buf:
003C 00 127 .db #0x00
003D 01 128 .db #0x01
003E 02 129 .db #0x02
003F 03 130 .db #0x03
0040 04 131 .db #0x04
0041 05 132 .db #0x05
Logged In: NO
I think that the function
checkDecl (symbol * sym, int isProto)
in SDCCsymt.c is the Problem.
This function inserts the second dimension in the open
dimenion
instead of the count of elements.
The sizeof this array is 4 but shold be 2.
code unsigned char tmp1[][2]={{0,1}};
tmp1[][2]={{1,2}};
The cdb-line is
S:G$tmp1$0$0({4}DA2,DA2,SC:U),D,0,0
the same for
code unsigned char tmp2[][4]={{0,1,1,3},{2,3,3,3}};
S:G$tmp2$0$0({16}DA4,DA4,SC:U),D,0,0
g.fink@gmx.net
Logged In: YES
user_id=203539
Fixed by Johan. The bug was also exposed in float.c of the
regression tests.