ppc64: Arguments to iselInt128Expr_to_32x4 should be initialized.
[valgrind.git] / memcheck / tests / origin2-not-quite.c
blobe2d2582058e1e0133da681892c932e2654ab141a
2 /* This test case was originally written by Nicholas Nethercote. */
4 // This test demonstrates some cases that the piggybacking algorithm
5 // doesn't handle but conceivably might, with more modifications.
6 // The instrumentation based algorithm handles them ok, though.
8 #include <assert.h>
9 #include <stdlib.h>
10 #include <stdio.h>
12 int x = 0;
14 typedef long long Long;
16 __attribute__((noinline)) int t1(void);
17 __attribute__((noinline)) int t2(void);
18 __attribute__((noinline)) int t3(void);
20 int main(void)
22 assert(4 == sizeof(int));
23 assert(8 == sizeof(Long));
25 x += t1();
26 x += t2();
27 x += t3();
29 return x & 255;
32 __attribute__((noinline)) int t1(void)
34 // 64-bit undefined double.
35 double* ptr_to_undef_double = malloc(sizeof(double));
36 double undef_double = *ptr_to_undef_double;
37 fprintf(stderr, "\nUndef 1 of 3 (64-bit FP)\n");
38 return (undef_double < (double)123.45 ? 12 : 23);
41 __attribute__((noinline)) int t2(void)
43 // 32-bit undefined float.
44 float* ptr_to_undef_float = malloc(sizeof(float));
45 float undef_float = *ptr_to_undef_float;
46 fprintf(stderr, "\nUndef 2 of 3 (32-bit FP)\n");
47 return (undef_float < (float)234.56 ? 13 : 24);
50 __attribute__((noinline)) int t3(void)
52 // Stack, 32-bit, recently modified.
53 // Problem here is that we don't chase backwards through loads and
54 // stores. Ie. the variable is stored after it's been modified, then
55 // loaded again, so we don't see the unmodified version.
56 int modified_undef_stack_int;
57 modified_undef_stack_int++;
58 fprintf(stderr, "\nUndef 3 of 3 (int)\n");
59 return (modified_undef_stack_int == 0x1234 ? 11 : 22);