[cfe-commits] r59931 - /cfe/trunk/test/Analysis/outofbound.c

Chris Lattner clattner at apple.com
Sun Nov 23 20:29:56 PST 2008


On Nov 23, 2008, at 6:19 PM, Zhongxing Xu wrote:

> Author: zhongxingxu
> Date: Sun Nov 23 20:19:49 2008
> New Revision: 59931
>
> URL: http://llvm.org/viewvc/llvm-project?rev=59931&view=rev
> Log:
> Add test case for out-of-bound memory access checking.
>
> Added:
>    cfe/trunk/test/Analysis/outofbound.c
>
> Added: cfe/trunk/test/Analysis/outofbound.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/outofbound.c?rev=59931&view=auto
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/test/Analysis/outofbound.c (added)
> +++ cfe/trunk/test/Analysis/outofbound.c Sun Nov 23 20:19:49 2008
> @@ -0,0 +1,6 @@
> +// RUN: clang -checker-simple -analyzer-store-region -verify %s
> +
> +char f1() {
> +  char* s = "abcd";
> +  return s[4]; // expected-warning{{Load or store into an out-of- 
> bound memory position.}}
> +}

Hi Zhongxing,

This is valid code - strings in C are null terminated, so this always  
returns '\0'.

-Chris



More information about the cfe-commits mailing list