This is the mail archive of the gcc-patches@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]

Returned mail: User unknown (fwd)


Hi,

I am adding the following testcase to gcc.c-torture/execute, this was 
failing when compiled with -O2.

20000523-1.c

#include <stdio.h>
int   flg = 0 ;
struct SRT {

    signed long     m1 ;
    signed int      m2 ;
    signed int      m3 ;
} ;

void foo(volatile struct SRT a1, volatile struct SRT ss)
{
   if (flg != 0) abort ();
   exit (0);
}

struct SRT func( volatile struct SRT a1, volatile struct SRT *a2 )
{
    struct SRT ss =  *((struct SRT *)&a1) ;

    ss.m1 = 1 ;
    ss.m2 = 1 ;
    ss.m3 = 1 ;

    a2 = &ss ;
    a1.m1 = (a2->m1 += 1) ;
    a1.m2 = (a2->m2 += 1) ;
    a1.m3 = (a2->m3 += 1) ;

    if ( ss.m1 != 2 || ss.m2 != 2 || ss.m3 != 2  ||
         a1.m1 != 2 || a1.m2 != 2 || a1.m3 != 2
    ) {
        flg = 1;
        foo (a1, ss);
    }


    return( ss ) ;
}

void main( void )
{
    volatile struct SRT dat = { 0, 0, 0 } ;

    dat =  func( dat, &dat ) ;
    exit (0);
}

Thanks
chandra








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