Kristian Adrup <[EMAIL PROTECTED]> writes:
> struct X {
> Int16 a[27];
> Char *b;
> };
>
> Then I try to declare an instance of it with an initializer...
>
> struct X thestruct = {{1},""};
Kristian tells me that this was a local definition inside a function,
rather than a global as I had earlier assumed.
> This results in thestruct getting filled with garbage. I've tried with
> different members in X, the pattern seems to be that sizeof(struct X)
> can't be >=58.
Right. When sizeof (struct X) < 58, GCC inlines the clearing of thestruct,
using a bunch of clr instructions. But when the struct is larger than the
threshold you've identified, it creates a global const temporary with the
value you want, and initialises thestruct with bcopy (i.e. memcopy):
pea .temporary(%pc)
bsr.w bcopy
But in this case, the temporary is in the global data (!), not the text
section. So the pea should be "pea .temporary@END(%a5)", and this is
indeed another example of the "Const objects + no optimization => crash"
bug, except that you've found an instance that is not fixed by turning
on the optimizer. Congratulations.
Especially because of the item in the global data created that's not under
your control, I think the best answer at the moment is: Don't do that.
John
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/