2 /* Check for correct handling of static vs non-static, local vs
3 non-local variables in a zero-biased executable. */
4 /* Relevant compile flags are:
6 -Wall -g -I$prefix/include/valgrind
8 eg -Wall -g -I`pwd`/Inst/include/valgrind
10 /* Unfortunately 2008 Feb 26, requires its own filter_varinfo3, since
11 nonstatic_local_{un}def are not handled properly and so end up with
12 compiler-dependent names, eg static_local_def.2919 and
13 static_local_undef.2921. So filter off the .nnnn part. */
17 #include "memcheck/memcheck.h"
18 /* Cause memcheck to complain about the address "a" and so to print
19 its best guess as to what "a" actually is. a must be
21 void croak ( void* aV
)
24 char* undefp
= malloc(1);
28 (void) VALGRIND_CHECK_MEM_IS_DEFINED(a
, 1);
35 static char static_global_def
[10] = {0,0,0,0,0, 0,0,0,0,0};
36 char nonstatic_global_def
[10] = {0,0,0,0,0, 0,0,0,0,0};
37 static char static_global_undef
[10];
38 char nonstatic_global_undef
[10];
40 void bar ( char* p1
, char* p2
, char* p3
, char* p4
)
50 static char static_local_def
[10] = {0,0,0,0,0, 0,0,0,0,0};
51 char nonstatic_local_def
[10] = {0,0,0,0,0, 0,0,0,0,0};
52 static char static_local_undef
[10];
53 char nonstatic_local_undef
[10];
54 croak ( 1 + (char*)&static_global_def
);
55 croak ( 2 + (char*)&nonstatic_global_def
);
56 croak ( 3 + (char*)&static_global_undef
);
57 croak ( 4 + (char*)&nonstatic_global_undef
);
58 bar( 5 + (char*)&static_local_def
,
59 6 + (char*)&nonstatic_local_def
,
60 7 + (char*)&static_local_undef
,
61 8 + (char*)&nonstatic_local_undef
);