[cfe-commits] [patch] Warn on sizeof(array_fun_arg)
Hans Wennborg
hans at chromium.org
Wed Jun 15 03:13:17 PDT 2011
On Wed, Jun 15, 2011 at 2:04 AM, Nico Weber <thakis at chromium.org> 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));
> }
Nice!
>
> It finds 0 bugs and 0 false positives in llvm/clang code and 2 bugs
> and 0 false positives in chrome/webkit.
>
> Ok?
>
> Nico
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
More information about the cfe-commits
mailing list