I did not want to start an other code duplication discussion, but indeed, a more generic solution would look something like this:
template <size_t n, size_t m> void test(int (& arr)[n][m]) {
// Element (i, j) can be accessed as `arr[i][j]`.
}
If code duplication is an issue, then perhaps the following would be a workaround, although it comes at the expense of easy indexing.
void test_(int* arr, size_t n, size_t m) {
// Element (i, j) can be accessed as `*(arr + i * n + j)`.
}
template <size_t n, size_t m> void test(int (& arr)[n][m]) {
test_(&arr[0][0], n, m);
}