va_arg and Alignment
D. Towner
towner@compsci.bristol.ac.uk
Wed Mar 6 08:12:00 GMT 2002
Hi all,
I am porting gcc to a 16-bit DSP. This can can only load/store 32-bit
values when they are aligned on 32-bit boundaries. Suppose I have the
following:
void f (int n, ...)
{
long l;
va_list ap;
va_start (ap,n);
l = va_arg(ap, long);
va_end (ap);
}
int main ()
{
f (3, (long) 123);
}
The call to `f' is correctly initialised, with the long value being
aligned on a 32-bit boundary. However, within `f', the va_arg line will
try to load the long value from a location which isn't on the correct
boundary (i.e., the 16-bit address of the last named parameter + 16-bits).
Why doesn't va_arg respect the aligment requirements of the arguments, and
what is the easiest way to fix this problem?
Thanks
dan.
=============================================================================
Daniel Towner
picoChip Designs Ltd., Riverside Buildings, 108, Walcot Street, BATH, BA1
5BG
dant@picochip.com
07786 702589
More information about the Gcc
mailing list