[PATCH] D67287: [Diagnostics] Add -Wsizeof-array-div
Leonard Chan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 13 15:07:36 PDT 2019
leonardchan added a comment.
Not sure if we're still mentioning false positives here, but if we have something like a multidimensional array of a specific type and we want to find the number of elements inside it, this warning would also appear:
int arr[][5] = {
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 0},
};
void func() {
unsigned num_elems = sizeof(arr) / sizeof(int); // Warns here
assert(num_elems == 10);
}
Although one could argue that `sizeof(arr) / sizeof(**arr)` would be better while not producing the warning.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67287/new/
https://reviews.llvm.org/D67287
More information about the llvm-commits
mailing list