1// Regression test for origin propagation in "select i1, float, float".
2// https://code.google.com/p/memory-sanitizer/issues/detail?id=78
3
4// RUN: %clangxx_msan -O2 -fsanitize-memory-track-origins %s -o %t && not %run %t >%t.out 2>&1
5// RUN: FileCheck %s < %t.out
6
7// RUN: %clangxx_msan -O2 -fsanitize-memory-track-origins=2 %s -o %t && not %run %t >%t.out 2>&1
8// RUN: FileCheck %s < %t.out
9
10#include <stdio.h>
11#include <sanitizer/msan_interface.h>
12
13int main() {
14 volatile bool b = true;
15 float x, y;
16 __msan_allocated_memory(data: &x, size: sizeof(x));
17 __msan_allocated_memory(data: &y, size: sizeof(y));
18 float z = b ? x : y;
19 if (z > 0) printf(format: ".\n");
20 // CHECK: Memory was marked as uninitialized
21 // CHECK: {{#0 0x.* in .*__msan_allocated_memory}}
22 // CHECK: {{#1 0x.* in main .*select_float_origin.cpp:}}[[@LINE-6]]
23 return 0;
24}
25

source code of compiler-rt/test/msan/select_float_origin.cpp