tests/vg_regtest: Always evaluate prerequisite expressions with sh
[valgrind.git] / memcheck / tests / err_disable2.c
blob4a68c869c61beef6d50cf76c1385dccdff423169
2 /* Test that we get a complaint if a thread exits with error reporting
3 disabled. */
5 #include <stdlib.h>
6 #include <stdio.h>
8 #include "../include/valgrind.h"
10 char* block = NULL;
12 __attribute__((noinline)) void usechar ( char c )
14 // Spook gcc into believing mysterious bad things are
15 // happening behind its back, and that 'c' is definitely
16 // used in some (unknown) way.
17 __asm__ __volatile__("" : : "r"(c) : "memory","cc");
20 __attribute__((noinline)) void err ( void )
22 usechar( block[5] );
25 int main ( void )
27 block = malloc(10);
28 free(block);
30 fprintf(stderr, "\n--------- enabled (expect 1) ---------\n\n");
32 err();
34 fprintf(stderr, "\n--------- disabled (expect 0) ---------\n\n");
35 VALGRIND_DISABLE_ERROR_REPORTING;
37 err();
39 fprintf(stderr, "\n--------- exiting (expect complaint) ---------\n\n");
41 return 0;