argument promotions in C function calls
Posted
by HaoCheng
on Stack Overflow
See other posts from Stack Overflow
or by HaoCheng
Published on 2010-05-31T11:46:09Z
Indexed on
2010/05/31
11:53 UTC
Read the original article
Hit count: 157
integer-promotion
I learned from ----As to when default promotions kick in: default argument promotions are used exactly when the expected type of the argument is unknown, which is to say when there's no prototype or when the argument is variadic.
But an example confusing me is:
void func(char a, char b)
{
printf("a=%p,b=%p\n",&a,&b);
}
int main(void)
{
char a=0x11,b=0x22;
func(a,b);
return 0;
}
It is cleard in the above example: when calling func in main, there is no need to promote the arguments a and b, but the output shows &a = &b +4 not &a = &b+1. If no promotion occured, why 4 bytes between two CHAR argument?
© Stack Overflow or respective owner