Open
Description
Unfortunately, C++ does not have the ever-so-useful restrict
keyword of C. Fortunately, compilers such as clang++ offer a __restrict
pseudo-keyword. Unfortunately, that keyword is only offered for pointers, not for array parameters. If we write:
int foo(int a[__restrict 10], int b[__restrict 10]) {
a[0] += b[0];
return a[0] + b[0];
}
int bar(int *a, int *b) {
a[0] += b[0];
return a[0] + b[0];
}
int baz(int * __restrict a, int * __restrict b) {
a[0] += b[0];
return a[0] + b[0];
}
then baz()
will be accepted by clang++ as C++, but foo()
will not (GodBolt).
Well, foo()
should be accepted! Taking array parameters is useful, especially if they are multi-dimensionsional. Without them,
See also this G++ bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97477