This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: double argument casting
- From: Ian Lance Taylor <iant at google dot com>
- To: laurent <laurent dot poche at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 22 Oct 2010 17:08:23 -0700
- Subject: Re: double argument casting
- References: <4CC0491E.1040107@gmail.com>
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