1 2/* Test that we get a complaint if a thread exits with error reporting 3 disabled. */ 4 5#include <stdlib.h> 6#include <stdio.h> 7 8#include "../include/valgrind.h" 9 10char* block = NULL; 11 12__attribute__((noinline)) void usechar ( char c ) 13{ 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"); 18} 19 20__attribute__((noinline)) void err ( void ) 21{ 22 usechar( block[5] ); 23} 24 25int main ( void ) 26{ 27 block = malloc(10); 28 free(block); 29 30 fprintf(stderr, "\n--------- enabled (expect 1) ---------\n\n"); 31 32 err(); 33 34 fprintf(stderr, "\n--------- disabled (expect 0) ---------\n\n"); 35 VALGRIND_DISABLE_ERROR_REPORTING; 36 37 err(); 38 39 fprintf(stderr, "\n--------- exiting (expect complaint) ---------\n\n"); 40 41 return 0; 42} 43