On Sat, 12 Dec 2015, Matthew Fortune wrote: > > > * config/mips/mips.c (mips_promote_function_mode): New function. > > > (TARGET_PROMOTE_FUNCTION_MODE): Define as above function. > > > (TARGET_PROMOTE_PROTOTYPES): Remove. > > I'm OK with this change on the basis that MIPS has been providing stronger > guarantees than required by the various standards. I.e. after this change > MIPS will have undefined behaviour for a mismatch in types between a > call to an un-prototyped function and its definition:
Indeed this is exactly what the current ISO C language standard mandates -- if an unprototyped call is made to a function whose definition has been prototyped and the types of the arguments after promotion are incompatible with the types of the respective parameters, then behaviour is undefined. > extern void foo(); > > void caller(int a) > { > foo(a); > } > > -- > > void foo(short a) > { > // the value of 'a' can be out of range of a short because the caller > // did not get the right type for the argument. > } Which is exactly the case with the piece of code you quoted. Behaviour of this code would be defined if the `a' parameter of `foo' was of the `int' type. See Section 6.5.2.2 "Function calls", clause 6, for details. Maciej