regtest: fix compiler warnings with clang 16
[valgrind.git] / memcheck / tests / err_disable_arange1.c
blobfbbecc9ff7918e49062348e96ac15c8a1cfc2ff0
2 /* Check some aspects of the use of the
3 VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE and
4 VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE macros. */
6 #include <stdio.h>
7 #include <stdlib.h>
9 #include "../memcheck.h"
11 int main ( void )
13 volatile int* volatile mem
14 = (volatile int* volatile)malloc(1000 * sizeof(int));
15 free((void*)mem);
17 // Check that we get an invalid access complaint
18 fprintf(stderr, "\nDoing invalid access. Expect complaint.\n\n");
19 mem[123] = 0;
21 // Now disable error reporting in the range
22 fprintf(stderr, "\nDisabling address error reporting for the range.\n\n");
23 VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE(mem, 1000 * sizeof(int));
25 // Check that we get an invalid access complaint
26 fprintf(stderr, "\nDoing invalid another access. Expect no complaint.\n\n");
27 mem[456] = 0;
29 // Re-enable reporting on the first byte of one word from the ignore range
30 fprintf(stderr, "\nPartially reenabling address error reporting.\n\n");
31 VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE(&mem[789], 1);
33 // Check that we get an invalid access complaint
34 fprintf(stderr, "\nDoing a third access. Expect complaint.\n\n");
35 mem[789] = 0;
37 // And now quit and expect to see a warning about two remaining ranges
38 fprintf(stderr, "\nExiting. Expect warnings of 2 remaining ranges.\n\n");
40 return 0;