powerpc-eabi signed char arguments and optimization

Brian Ford ford@vss.fsi.com
Mon Oct 26 07:47:00 GMT 1998


Nice try, but no cigar.  This patch updates C++ code and my test case only
uses the C compiler.

On Sat, 24 Oct 1998, Robert Lipe wrote:

> I have no particular understanding of this patch, but I do think I
> recognize this problem.  I don't know if this patch will apply cleanly
> to 1.1, but I suspect it could be stitched in pretty easily.  I've
> checked and this work does indeed postdate 1.1.
> 
> 
> 1998-08-24  Gavin Romig-Koch  <gavin@cygnus.com>
> 
>         * typeck.c (c_expand_return): Handle the case that valtype
>         is wider than the functions return type.
> 
> Index: typeck.c
> ===================================================================
> RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/typeck.c,v
> retrieving revision 1.99
> retrieving revision 1.100
> diff -u -p -r1.99 -r1.100
> --- typeck.c    1998/08/24 11:12:27     1.99
> +++ typeck.c    1998/08/24 16:31:38     1.100
> @@ -7362,9 +7362,17 @@ c_expand_return (retval)
>      }
>    else
>      {
> +      tree functype = TREE_TYPE (TREE_TYPE (current_function_decl));
> +
> +      /* First convert the value to the function's return type, then
> +        to the type of return value's location to handle the
> +         case that functype is thiner than the valtype. */
> +
>        retval = convert_for_initialization
> -       (NULL_TREE, valtype, retval, LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING,
> +       (NULL_TREE, functype, retval, LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING,
>          "return", NULL_TREE, 0);
> +
> +      retval = convert (valtype, retval);
> 
>        if (retval == error_mark_node)
>         {
> 
> 
> 
> 
> 
> 
> Brian Ford wrote:
> > I have a sparc-sun-solaris2.6 -> powerpc-unknown-eabi cross compiler from
> > egcs1.1b - current CVS sources that gives me this problem.  Note that this
> > is a simulation of the actual problem as the embedded system I use cannot
> > execute this exact code.
> > 
> > #include <stdio.h>
> > 
> > void test(signed char a) {
> > 
> >    printf("a: %x\n", a);
> > 
> > }
> > 
> > int main(void) {
> >    signed char a = -60;
> > 
> >    test(a);
> > 
> >    return 0;
> > }
> > 
> > Output with -O0:
> > a: c4
> > 
> > Output with -O1+
> > a: 107cec4
> > 
> > Anybody know why this happens?  GCC 2.8.1 does not do this.
> > 
> > --
> > Brian Ford
> > Software Engineer
> > Vital Visual Simulation Systems
> > FlightSafety International
> > Phone: 314-551-8460
> > Fax:   314-551-8444
> > 
> 

--
Brian Ford
Software Engineer
Vital Visual Simulation Systems
FlightSafety International
Phone: 314-551-8460
Fax:   314-551-8444




More information about the Gcc-bugs mailing list