1 // Simple program that uses C99 restrict qualifier.
2 // Once GCC is fixed to output DW_TAG_restrict_type in the debuginfo
3 // valgrind --read-var-info=yes would get a serious error reading the
4 // debuginfo. This tests makes sure that a fixed GCC and a fixed valgrind
6 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59051
7 // https://bugs.kde.org/show_bug.cgi?id=336619
14 #include "memcheck/memcheck.h"
16 /* Cause memcheck to complain about the address "a" and so to print
17 its best guess as to what "a" actually is. a must be addressible. */
18 void croak (void *aV
)
21 char* undefp
= malloc(1);
25 (void) VALGRIND_CHECK_MEM_IS_DEFINED(a
, 1);
31 bad_restrict_ptr (void * restrict bad_ptr
)
33 croak ((void *) &bad_ptr
);
37 cpy (char * restrict s1
, const char * restrict s2
, size_t n
)
47 main (int argc
, char **argv
)
49 const char *hello
= "World";
50 size_t l
= strlen (hello
) + 1;
51 char *earth
= malloc (l
);
52 fprintf (stderr
, "Hello %s\n", cpy (earth
, hello
, l
));
55 void *bad
= malloc (16);
56 bad_restrict_ptr (bad
);