You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While discussing my patch for this rule to clang-tidy (http://reviews.llvm.org/D13311), the following example code was presented:
void f(int ar[], size_t s) {
a[1] = 0;
}
Is the access to ar considered "pointer arithmetic" and thus forbidden under this rule?
My current patch flags all operators +, -, +=, -=, ++ and -- that yield a pointer type. In addition, it flags the use of operator [] on pointer types. Clearly, using operator [] on an array with known size is okay under this rule (and subject to rule Bounds.2).
2) Are any other operations considered "pointer arithmetic" and thus forbidden under this rule?
Please add the details to the "Enforcement" part of this rule.
The text was updated successfully, but these errors were encountered:
I believe the access to ar is pointer arithmetic due to array to pointer decay. However, I would also suggest that this may be a reasonable way to silence the diagnostic for legacy code that cannot make use of array_view (for instance, due to ABI issues).
The use is pointer arithmetic because the parameter ar is a pointer, not an array -- there is no concept of array parameter in C or C++. This is a typical case where we recommend people use array_view.
While discussing my patch for this rule to clang-tidy (http://reviews.llvm.org/D13311), the following example code was presented:
My current patch flags all operators +, -, +=, -=, ++ and -- that yield a pointer type. In addition, it flags the use of operator [] on pointer types. Clearly, using operator [] on an array with known size is okay under this rule (and subject to rule Bounds.2).
2) Are any other operations considered "pointer arithmetic" and thus forbidden under this rule?
Please add the details to the "Enforcement" part of this rule.
The text was updated successfully, but these errors were encountered: