double argument casting
Ian Lance Taylor
iant@google.com
Sat Oct 23 00:39:00 GMT 2010
laurent <laurent.poche@gmail.com> writes:
> When a caller function calls a callee function with short or char
> arguments, the arguments are casted twice: inside the caller function
> and inside the callee function, see the example. It is a waste of
> performance in code density and speed!
>
> I don't understand why there is a double casting. Is there any
> optimization I could activate in GCC to remove it?
It's basically a bug. gcc should only do it on the caller side. Doing
it on the callee side is a holdover from the good pre-C90 days, when
code like
int f(i)
char i;
{
...
}
had to be treated as equivalent to
int f(int passed_i)
{
char i = (char) passed_i;
...
}
These days I think we can just drop the cast on the callee side. As I
recall that was done for x86 a while back, somebody just needs to do it
for SPARC.
Please file a bug report according to the instructions at
http://gcc.gnu.org/bugs/ (unless there is already a bug report for
this). Thanks.
Ian
More information about the Gcc-help
mailing list