Open llvmbot opened 15 years ago
+1 — Still a problem as of Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
cloned to rdar://problem/11957587
Still hitting this:
Apple clang version 4.0 (tags/Apple/clang-421.0.55) (based on LLVM 3.1svn)
assigned to @tkremenek
Extended Description
Description: The static analyzer does not warn of assigning autoreleased objects into a static variable.
Steps to reproduce: int main(int argc, char argv[]) { static NSString foo = nil; NSAutoreleasePool pool = [[NSAutoreleasePool alloc] init]; NSMutableArray f = [NSMutableArray array]; for(int i = 0; i < 10; ++i) { [f addObject:[NSString stringWithFormat:@"%d", i]]; } foo = [f componentsJoinedByString:@","]; [pool drain]; printf("%s\n", [foo UTF8String]); return 0; }
Actual results: I can compile and analyze, all with no warnings of any kind. When the app runs, it crashes with "EXC_BAD_ACCESS" (as "expected").
Expected results: The analyzer should warn me that I'm assigning an autoreleased object into a static variable. In GUI applications especially, where autoreleasepools are created and destroyed frequently, this can be quite detrimental.
Build date: 11 September 2009, Mac OS X 10.6, Xcode 3.2 (built-in analyzer) 11 September 2009, Mac OS X 10.5, Xcode 3.1, checker 0.219