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

Douglas Gregor dgregor at apple.com
Tue Jun 14 19:48:21 PDT 2011


On Jun 14, 2011, at 6:04 PM, Nico Weber wrote:

> 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?

Looks good to me.

	- Doug



More information about the cfe-commits mailing list