[llvm-bugs] [Bug 42533] New: Objective-C pointer bug with fobjc-arc

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 8 03:38:59 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42533

            Bug ID: 42533
           Summary: Objective-C pointer bug with fobjc-arc
           Product: clang
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mike.kluev at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

when compiling the following app with "-fobjc-arc -Werror" option i am not
getting expected compilation error. the app crashes at run time, obviously.
without "-fobjc-arc" option compiler issues a warning / error as expected.

============
#import <Foundation/Foundation.h>

@interface Animal: NSObject
@end

@implementation Animal
@end

@interface Dog: Animal
- (void)bark;
@end

@implementation Dog
- (void)bark {}
@end

void bark(Dog** dog) {
    [*dog bark];
}

int main(int argc, const char* argv[]) {
    Animal* animal = [Animal new];
    bark(&animal);
}

============
// same with foundation types

#import <Foundation/Foundation.h>

void foo(NSMutableDictionary** mutableDictionary) {
    (*mutableDictionary)[@"hello"] = @"world";
}

int main(int argc, const char* argv[]) {
    NSDictionary* dictionary = [NSDictionary new];
    foo(&dictionary);
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190708/cf0caf87/attachment.html>


More information about the llvm-bugs mailing list