1 | // RUN: %clang_asan %s -o %t -framework Foundation |
2 | // RUN: %run %t 2>&1 | FileCheck %s |
3 | |
4 | #import <Foundation/Foundation.h> |
5 | |
6 | struct MyStruct { |
7 | long a, b, c, d; |
8 | }; |
9 | |
10 | @interface MyClass: NSObject |
11 | - (MyStruct)methodWhichReturnsARect; |
12 | @end |
13 | @implementation MyClass |
14 | - (MyStruct)methodWhichReturnsARect { |
15 | MyStruct s; |
16 | s.a = 10; |
17 | s.b = 20; |
18 | s.c = 30; |
19 | s.d = 40; |
20 | return s; |
21 | } |
22 | @end |
23 | |
24 | int main() { |
25 | MyClass *myNil = nil; // intentionally nil |
26 | [myNil methodWhichReturnsARect]; |
27 | fprintf(stderr, "Hello world" ); |
28 | } |
29 | |
30 | // CHECK-NOT: AddressSanitizer: stack-use-after-scope |
31 | // CHECK: Hello world |
32 | |