| 1 | // RUN: %clangxx_tysan -O0 %s -o %t && %run %t >%t.out 2>&1 |
|---|---|
| 2 | // RUN: FileCheck %s --implicit-check-not ERROR < %t.out |
| 3 | |
| 4 | // Modified reproducer from https://github.com/llvm/llvm-project/issues/105960 |
| 5 | |
| 6 | #include <stdio.h> |
| 7 | |
| 8 | struct inner1 { |
| 9 | char buffer; |
| 10 | int i; |
| 11 | }; |
| 12 | |
| 13 | struct inner2 { |
| 14 | char buffer; |
| 15 | int i; |
| 16 | float endBuffer; |
| 17 | }; |
| 18 | |
| 19 | void init_inner1(inner1 *iPtr) { iPtr->i = 200; } |
| 20 | void init_inner2(inner2 *iPtr) { |
| 21 | iPtr->i = 400; |
| 22 | iPtr->endBuffer = 413.0f; |
| 23 | } |
| 24 | |
| 25 | struct outer { |
| 26 | inner1 foo; |
| 27 | inner2 bar; |
| 28 | char buffer; |
| 29 | }; |
| 30 | |
| 31 | int main(void) { |
| 32 | outer *l = new outer(); |
| 33 | |
| 34 | init_inner1(iPtr: &l->foo); |
| 35 | init_inner2(iPtr: &l->bar); |
| 36 | |
| 37 | int access = l->foo.i; |
| 38 | printf(format: "Accessed value 1 is %d\n", access); |
| 39 | access = l->bar.i; |
| 40 | printf(format: "Accessed value 2 is %d\n", access); |
| 41 | float fAccess = l->bar.endBuffer; |
| 42 | printf(format: "Accessed value 3 is %f\n", fAccess); |
| 43 | |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | // CHECK: Accessed value 1 is 200 |
| 48 | // CHECK: Accessed value 2 is 400 |
| 49 | // CHECK: Accessed value 3 is 413.0 |
| 50 |
