Elimination of duplicate sign extensions

Mark Mitchell mark@codesourcery.com
Thu Sep 13 20:54:00 GMT 2007


Paul Brook wrote:

> IIUC TARGET_PROMOTE_PROTOTYPES deliberately introduces an asymmetric calling 
> convention. i.e. the caller must promote the value and the callee may not 
> assume the value is promoted. From the documentation of the hook, this 
> appears to be a deliberate feature to workaround broken code with mismatches 
> prototypes.

I guess an example of where this helps is (invalid) code like this:

a.c
---
void f(char c);
void g() { f('a'); }

b.c
---
void f(short s) {}

Here, absent TPP, the char argument to "f" would not be promoted, so
we'd have a char where we want a short.  By extending in the caller, we
make sure that we get a valid value to the callee.

I still don't quite get why we need to extend in the callee, though.

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713



More information about the Gcc-patches mailing list