descent@u64:simple_compiler$ cat test_pattern/p6.c // pointer test int main() { int x,y; int a,b; int *p; x=987; y=29; p=&x; //p = 100; a=*p; //printf("a: %d\n", a); p=&y; a=*p; //printf("new a: %d\n", a); //printf("a: %d, p: %p\n", a, p); printf("&x: %p\n", &x); p=100; printf("p: %d\n", p); *p; } descent@u64:simple_compiler$ ./c_parser < test_pattern/p6.c \tree( root( prog( main |int |func |global( func_body( var(x |int)(y |int))( var(a |int)(b |int))( var(p |ptr<1> |int))( =(x)(987))( =(y)(29))( =(p)( &(x)))( =(a)( *(p)))( =(p)( &(y)))( =(a)( *(p)))( printf(&x: \%p\\n)( &(x)))( =(p)(100))( printf(p: \%d\\n)(p))( *(p))))(main))) op: root &x: 1632ff0 p: 100 Segmentation fault (core dumped)
沒有留言:
張貼留言