aaron.ballman added inline comments.
================
Comment at:
clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp:40
@@ +39,3 @@
+
+ diag(MatchedCast->getExprLoc(), "do not (implicitly) convert an array to a
pointer");
+}
----------------
klimek wrote:
> aaron.ballman wrote:
> > klimek wrote:
> > > Can't we provide a fixit?
> > I think the fixit that the C++ Core Guidelines wants is to use array_view,
> > which isn't available to everyone and can't be applied locally (for
> > instance, it may require changing a function parameter instead of the
> > argument passed to the function).
> https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds3-no-array-to-pointer-decay
> says that &a[0] is an OK work around (makes the thing visible)
Hmm, I missed that part, but you're right. I wonder if they intended that to be
used as a workaround or not, however. It's not an array decay because it's an
explicit subscript of the array, and a unary op. It's certainly a functional
workaround, though. I would worry about more complex cases:
```
size_t g();
void h(int *);
void f() {
int a[5];
h(a + g() - 10); // Convert to &a[g() - 10];
}
```
http://reviews.llvm.org/D13640
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits