pointer-arith-1.c

来自「linux下编程用 编译软件」· C语言 代码 · 共 40 行

C
40
字号
/* Test diagnostics for arithmetic on void and function pointers.   Test with no special options.  *//* Origin: Joseph Myers <joseph@codesourcery.com> *//* { dg-do compile } *//* { dg-options "" } */void *p;void (*f)(void);voidg (void){  p + 0;  p + 1;  0 + p;  1 + p;  p - 0;  p - 1;  p += 0;  p += 1;  p -= 0;  p -= 1;  f + 0;  f + 1;  0 + f;  1 + f;  f - 0;  f - 1;  f += 0;  f += 1;  f -= 0;  f -= 1;  p[0]; /* { dg-warning "warning: dereferencing 'void \\*' pointer" } */  0[p]; /* { dg-warning "warning: dereferencing 'void \\*' pointer" } */  f[0]; /* { dg-error "error: subscripted value is pointer to function" } */  0[f]; /* { dg-error "error: subscripted value is pointer to function" } */  p - p;  f - f;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?