> Wojtek Lerch said:
>> The funny thing is that I don't think the result of converting between a
>> data pointer and a function pointer by va_arg() is defined anywhere --
>> it seems to me that the text specifically says that the behaviour is not
>> undefined, but fails to define the behaviour...
I wrote:
> Then it's undefined behaviour. Failing to define behaviour is the same as
> saying "it's undefined".
Seeds, Glen said:
> I'm a little uncomfortable with the last statement.
Sorry, but that's stated *explicitly* in C90 and C99.
However, in this instance I think I misspoke.
Wojtek is, I presume, talking about code like this:
typedef void (*vif_ptr)(int);
void f (int n, ...)
{
va_list ap;
vif_ptr fptr;
va_start (ap, n);
fptr = va_arg (ap, vif_ptr);
va_end (ap);
(*fptr)(n);
}
// ...
int x;
f (42, &x);
That is, the argument type is an object pointer but va_arg fetches a
function pointer (or vice versa).
If so, then this is *explicitly* undefined behaviour (7.15.1.1#2).
--
Clive D.W. Feather | Work: <yyyyy@xxxxxxxxx> | Tel: +44 20 8371 1138
Internet Expert | Home: <yyyyy@xxxxxxxxxx> | Fax: +44 870 051 9937
Demon Internet | WWW: http://www.davros.org | Mobile: +44 7973 377646
Thus plc | | NOTE: fax number change
|