Bug in vbcc backend?
VladisM opened this issue · 1 comments
VladisM commented
Probably bug in vbcc backend:
char strA[2][32] = {{"Hello world A!"}, {"Hello World B!"}};
char *strB[2];
int main(){
strB[0] = &strA[0][0];
strB[1] = &strA[1][0];
return 0;
}
strB is array of pointers to char, vbcc compile it into:
.EXPORT main
main:
PUSH R13
OR R0 SP R13
PUSH R1
PUSH R2
PUSH R3
PUSH R4
MVIA R1 strA
ST R1 strB
MVIA R1 strA
MVIA R2 strB
MVIA R3 1
ADD R2 R3 R2
STI R1 R2
OR R0 R0 R5
L_1:
POP R4
POP R3
POP R2
POP R1
OR R0 R13 SP
POP R13
RET
.EXPORT strA
strA:
.DAT 72
.DAT 101
.DAT 108
.DAT 108
.DAT 111
.DAT 32
.DAT 119
.DAT 111
.DAT 114
.DAT 108
.DAT 100
.DAT 32
.DAT 65
.DAT 33
.DAT 0
.DS 17
.DAT 72
.DAT 101
.DAT 108
.DAT 108
.DAT 111
.DAT 32
.DAT 87
.DAT 111
.DAT 114
.DAT 108
.DAT 100
.DAT 32
.DAT 66
.DAT 33
.DAT 0
.DS 17
.EXPORT strB
strB:
.DS 2
in main function, after function head, vbcc try to load address of strA[0][0] into strB[0], and that is correct, but it will load same strA[0][0] address into strB[1], in strB[1] should be strA[1][0] instead
I tested it with gcc and code worked as expected.