diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-03-29 21:43:21 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-03-29 21:43:21 +0000 |
commit | 52b2e7085f09bf7834b41f6e807aff5ac97bd3a5 (patch) | |
tree | c9d811aec773665c8096a45f211851ed03c62441 /test/Sema/expr-comma.c | |
parent | 9b97adfb770c3b55c1a45049d53b624bbc6f62e1 (diff) |
Sema: Warn on sizeof on binary ops on decayed arrays.
The array will decay into a pointer, creating an unexpected result.
sizeof(array + int) is an easy to make typo for sizeof(array) + int.
This was motivated by a NetBSD security bug, used sizeof(key - r) instead of
sizeof(key) - r, reducing entropy in a random number generator.
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/subr_cprng.c.diff?r1=1.14&r2=1.15&only_with_tag=MAIN&f=h
Differential Revision: http://llvm-reviews.chandlerc.com/D571
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178371 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/expr-comma.c')
-rw-r--r-- | test/Sema/expr-comma.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/test/Sema/expr-comma.c b/test/Sema/expr-comma.c index 7902715915..e2beafe236 100644 --- a/test/Sema/expr-comma.c +++ b/test/Sema/expr-comma.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c89 +// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c89 -Wno-sizeof-array-decay // expected-no-diagnostics // rdar://6095180 |