pmontgom@SM.UNISYS.COM (Peter Montgomery) (09/22/88)
/* On a SUN 3 at OS 4.0, GCC 1.28 warns "argument passing between incompatible pointer types" for the call to mat_print. The warning does not appear if "const" is omitted from the declaration of mat_print. GCC 1.26 did not give this warning. The object code is correct, with or without optimization. */ void mat_print(const int mat[2][2]) { printf("Matrix elements are %d %d %d %d\n", mat[0][0], mat[0][1], mat[1][0], mat[1][1]); } main() { int a[2][2] = {10, 20, 30, 40}; mat_print(a); }
drh@notecnirp.Princeton.EDU (Dave Hanson) (09/22/88)
In article <8809220411.AA01379@check.sm.unisys.com> pmontgom@SM.UNISYS.COM (Peter Montgomery) writes: /* On a SUN 3 at OS 4.0, GCC 1.28 warns "argument passing between incompatible pointer types" for the call to mat_print. The warning does not appear if "const" is omitted from the declaration of mat_print. GCC 1.26 did not give this warning. The object code is correct, with or without optimization. */ void mat_print(const int mat[2][2]) { printf("Matrix elements are %d %d %d %d\n", mat[0][0], mat[0][1], mat[1][0], mat[1][1]); } main() { int a[2][2] = {10, 20, 30, 40}; mat_print(a); } i think this is correct. the type of the argument to mat_print is `pointer to array of const int'. in main(), the type of a is `pointer to array of int'. those two types are not assignment compatible.