[cfe-commits] [patch] Warn on sizeof(array_fun_arg)

Nico Weber thakis at chromium.org
Tue Jun 14 18:04:20 PDT 2011


Hi,

the attached patch produces this diagnostic

test/Sema/warn-sizeof-arrayarg.c:14:15: warning: sizeof on array
function parameter will return size of 'int *' instead of 'int [10]'
[-Wsizeof-array-argument]
  (void)sizeof(a);  // \
              ^
test/Sema/warn-sizeof-arrayarg.c:7:12: note: declared here
void f(int a[10], Arr arr) {  // \
           ^

for this code:

  void f(int a[10]) {
    compute_hash(a, sizeof(a));
  }

It finds 0 bugs and 0 false positives in llvm/clang code and 2 bugs
and 0 false positives in chrome/webkit.

Ok?

Nico
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-sizeof-arrary-arg.patch
Type: application/octet-stream
Size: 3468 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110614/97d97d0c/attachment.obj>


More information about the cfe-commits mailing list