modernc.org/ccgo/v3@v3.16.14/lib/testdata/bug/objv.c (about)

     1  struct obj {
     2  	void *a;
     3  	void *b;
     4  };
     5  
     6  void g(void *p) {}
     7  
     8  struct obj **f(struct obj **objv) {
     9  	g(*objv++);
    10  	return objv;
    11  }
    12  
    13  struct obj **f2(struct obj *objv[]) {
    14  	// Bug: increment objv by sizeof obj.
    15  	// Should increment by sizeof obj*.
    16  	g(*objv++);
    17  	return objv;
    18  }
    19  
    20  int main() {
    21  	struct obj obj;
    22  	struct obj* objv[] = {&obj, &obj};
    23  	__builtin_printf("%d %d\n", f(objv) == &objv[1], f2(objv) == &objv[1]);
    24  	__builtin_printf("%d %d\n", f(objv) == objv+1, f2(objv) == objv+1);
    25  }