view test/tmp7.c @ 94:1ad7045741a7 dbinop

float dbinop fix
author kono
date Wed, 12 Mar 2003 15:28:44 +0900
parents b1c8ac8c308d
children 096559f07a70
line wrap: on
line source



int k=3;

struct aa { int a[100]; } aaa,bbb;

void tmp(void);

struct aa
main0(int);

struct aa
main0(int k)
{
    int i;
    struct aa ccc;

    for(i=0;i<100;i++) ccc.a[i]=i;
    ccc.a[55]=k;
    return ccc;
}

struct aa
main3(struct aa arg)
{
    int j=++arg.a[55];
    return main0(j);
}

void
main2(struct aa a1)
{
/* main2 a1.a[99] 0 */
/* main2 a1.a[55] 0 */
/* main2 a1.a[99] 55 */
/* main2 a1.a[55] 44 */
	printf("main2 a1.a[99] %d\n",a1.a[99]);
	printf("main2 a1.a[55] %d\n",a1.a[55]);
}

void
main1(struct aa a1)
{
/* main1 a1.a[0] 0 */
/* main1 a1.a[0] 44 */
    printf("main1 a1.a[0] %d\n",a1.a[0]);
    a1.a[55]=44;
    if (a1.a[0]) 
	main2(a1);
    else
	main2(aaa);
} 


main(ac,av)
int ac;
char *av[];
{
    register int i;
    register char *p;
    int j = 3;
    struct { int b; void (*c)(struct aa); } q = {3,main1},r;
    struct aa *aap[3];

    j = 3;

    bbb = main0(123);
    printf("copied main0 ccc.a[55] %d==123\n",bbb.a[55]); 
    aap[2] = &bbb;
    *aap[2] = main0(123);
    printf("complex copied main0 ccc.a[55] %d==123\n",bbb.a[55]); 
    bbb.a[55]=0;
    j = main0(123).a[55];
    printf("new main0 ccc.a[55] in temporal copy %d==123\n",j); 

    j = 552;
    bbb = main3(bbb);
    printf("main3     bbb.a[55] in temporal copy %d==552 %d==1\n",j,bbb.a[55]); 
    j = main3(bbb).a[55];
    printf("main3     bbb.a[55] in temporal copy %d==2 %d\n",j,bbb.a[53]); 
    j = main3(bbb).a[53];
    printf("main3     bbb.a[55] in temporal copy %d==53 %d\n",j,bbb.a[53]); 

    printf("%d==3\n",q.b);
/* 3==3 */
    r = q;
    printf("%d==3\n",r.b);
/* 3==3 */
    (*r.c)(aaa);
    printf("main aaa.a[55] %d\n",aaa.a[55]);
/* main aaa.a[55] 123 */
    bbb.a[0]=44; 
    aaa = bbb;
    aaa.a[99]=55;  /* core dump? */
    (*r.c)(aaa);
/* main aaa.a[55] 0 */
    printf("main aaa.a[55] %d\n",aaa.a[55]); 
    p = av[0];
    if (!p) return;
    i = p[1];
    p = p+i;
/* 47 ./a.out */
    printf("%d %s\n",i,p-i);
}

void
tmp()
{
}