mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-02-01 16:31:10 +00:00
Fix a problem where zero-initializing a one-byte array would crash the system.
Also, generate better code for zero-initializing small arrays. The problem was that the code would call the library routine ~ZERO with a size of 1, but it only works properly with a size of 2 or more. While adding a check here, I also changed it to not call ~ZERO for other small arrays (<=10 bytes), since it is generally more efficient to just initialize them directly. The initializations in the following are examples that could trigger the problem: int main(void) { struct { int i; char s[1]; } foo = {1, 0}; char arr[2][1] = {2}; }
This commit is contained in:
parent
fa5974199d
commit
972b0109a4
@ -3662,7 +3662,9 @@ procedure DoStatement;
|
||||
with iPtr^.itree^ do
|
||||
if token.kind = intconst then
|
||||
if token.ival = 0 then
|
||||
ZeroFill := true;
|
||||
{don't call ~ZERO for very small arrays}
|
||||
if elements * itype^.size > 10 then
|
||||
ZeroFill := true;
|
||||
end; {ZeroFill}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user