This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

target/6431: v850-elf-gcc, va_arg() fails in expanding arguments



>Number:         6431
>Category:       target
>Synopsis:       v850-elf-gcc, va_arg() fails in expanding arguments
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 23 11:16:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Markku Pihlajamaa
>Release:        gcc version 2.96-xscale-010827
>Organization:
>Environment:
GNU C cross compiler, configured for the v850-elf target, the compiler is run on a PC and the operating system is
Red Hat Linux 7.1.
>Description:
The first optional argument is not expanded by
va_arg() at all, but is skipped, and the last
optional argument is expanded to a random number.
>How-To-Repeat:
#include <stdarg.h>

extern int out ( int );

void test( int parc, ... )
{
    va_list list;

    va_start( list, parc );

    while( parc )
    {
        int i;

        i = va_arg( list, int );

        out( i );

        parc --;
    }

    va_end( list );
}


int main( void )
{
    test( 4, 1, 2, 3, 4 );

    return 0;
}
>Fix:
*** gcc/config/v850/v850.c.original	Sat Jan  8 10:15:57 2000
--- gcc/config/v850/v850.c	Tue Apr 23 13:55:30 2002
***************
*** 3653,3659 ****
    incr = build (MODIFY_EXPR, ptr_type_node, valist, incr);
    TREE_SIDE_EFFECTS (incr) = 1;
-   expand_expr (incr, const0_rtx, VOIDmode, EXPAND_NORMAL);
  
    addr_rtx = expand_expr (addr, NULL, Pmode, EXPAND_NORMAL);
  
    if (indirect)
--- 3653,3660 ----
    incr = build (MODIFY_EXPR, ptr_type_node, valist, incr);
    TREE_SIDE_EFFECTS (incr) = 1;
  
    addr_rtx = expand_expr (addr, NULL, Pmode, EXPAND_NORMAL);
+ 
+   expand_expr (incr, const0_rtx, VOIDmode, EXPAND_NORMAL);
  
    if (indirect)
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]