-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Open
Labels
c++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"enhancementImproving things as opposed to bug fixing, e.g. new or missing featureImproving things as opposed to bug fixing, e.g. new or missing featureextension:clangextension:gnu
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
Metadata
Metadata
Assignees
Labels
c++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"enhancementImproving things as opposed to bug fixing, e.g. new or missing featureImproving things as opposed to bug fixing, e.g. new or missing featureextension:clangextension:gnu