D
David Thompson
Not quite. You can 'cross' these if (and only if) the prototype formYou have to define the function the same way you declared it
though; e.g. you can't have a prototype declaration and a
K&R style definition. (The compiler is not required to
diagnose this either, you just get weird runtime behaviour).
matches _the result of applying default argument promotions to_ the
nonprototype form. This is tricky and system-dependent enough that the
PP is unlikely to get it right, and the people who know enough to get
it right are unlikely to want to do it. About the only case I would
approve of would be where you have to interface to legacy code that
you literally can't change _at all_ not even 'syntax cleanup'. There
is never a technical need for this, but there can be legal ones.
And yes if you do get it wrong it's UB. Although in a number of simple
cases it accidentally works, because it is fairly common for calling
conventions to promote everything to at least a (machine dependent)
'word' and this often just happens to do the same thing the default
promotions do. The Standard default promotions, of course, are partly
based on what the PDP-11 convention actually did.
- formerly david.thompson1 || achar(64) || worldnet.att.net