llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.02k stars 11.96k forks source link

False positive for potentially memory leak after transferring ownership to C array storage of > 1 dimension #19340

Open llvmbot opened 10 years ago

llvmbot commented 10 years ago
Bugzilla Link 18966
Version 3.3
OS MacOS X
Attachments Self contained .m file
Reporter LLVM Bugzilla Contributor
CC @belkadan

Extended Description

When retained objects are assigned into a C array of greater than 1 dimension in a longer lived scope, the objects a potential leak is reported. I have tried this with a static global 2d array and an instance ivar. Attached test case contains both flavors.

Note that the same error does not occur with a 1d array.

belkadan commented 10 years ago

Cloned to rdar://problem/16173744

belkadan commented 10 years ago

More data: if the second index is replaced by a constant, or the first index is replaced by 0, the warning goes away.

My guess is that the analyzer is just unable to represent the location "foo[x][y]", because it's "&foo + x * sizeof(foo[0]) + y".

llvmbot commented 10 years ago

assigned to @tkremenek