Re: Hellp with type promotion



"Robin Haigh" <ecl6rsh@xxxxxxxxxxx> wrote in news:du1qg6$7jd$1
@newsg3.svr.pol.co.uk:


<manochavishal@xxxxxxxxx> wrote in message
news:1141134465.963604.87530@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

void test();
....

void test(c)
{
printf("size in func %d",sizeof(c));
}

....
But here's the odd thing. If you change the call

test(c);

to

test();

so that you don't pass an argument at all, you still get the same
output

How is that odd? (Except that the code looks like it is from the 80s).

You have circumvented the prototype system. When func is called, it is
set up to receive one int argument. The value might be crap, but that
doesn't really matter because sizeof does not evaluate its operand.

Of course, IMHO, anyone who writes code like this in this day and age
deserves whatever they get.

Sinan
--
A. Sinan Unur <1usa@xxxxxxxxxxxxxxxxxxx>
(reverse each component and remove .invalid for email address)
.