mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-06-17 20:29:31 +00:00
Fix bug in initialization of auto arrays of strings.
When initializing (e.g.) an array of arrays of char, a string literal would be taken as an initializer for the outer array rather than for an inner array, so not all elements would be initialized properly. This was a bug introduced in commit 222c34a385
.
This bug affected the C4.6.4.2.CC test case, and the following reduced version:
#include <stdio.h>
#include <string.h>
int main (void) {
char ch2[][20] = {"for all good people", "to come to the aid "};
if (strcmp(ch2[1], "to come to the aid "))
puts("Failed");
}
This commit is contained in:
parent
3997fc6dce
commit
1fb1762458
|
@ -4423,6 +4423,7 @@ var
|
|||
arrayType: begin
|
||||
elements := itype^.elements;
|
||||
if elements = 0 then goto 1; {don't init flexible array member}
|
||||
if itype^.aType^.kind = scalarType then
|
||||
if iPtr^.iTree^.token.kind = stringConst then begin
|
||||
elements := elements * itype^.aType^.size;
|
||||
size := iPtr^.iTree^.token.sval^.length;
|
||||
|
|
Loading…
Reference in New Issue
Block a user