[LLVMbugs] [Bug 16626] New: Objective-C method writeback parameter marked "out" does not allow passing more generic pointer type, unless -fobjc-arc is enabled
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Jul 14 14:47:47 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=16626
Bug ID: 16626
Summary: Objective-C method writeback parameter marked "out"
does not allow passing more generic pointer type,
unless -fobjc-arc is enabled
Product: clang
Version: 3.3
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: jtbandes at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
With the following classes:
@interface Foo @end
@implementation Foo @end
@interface Bar : Foo @end
@implementation Bar @end
@interface Nothing
+ (void)blah:(out Bar **)b;
@end
@implementation Nothing
+ (void)blah:(out Bar **)b { }
@end
One would expect to be able to pass the address of a Foo* object in for the
writeback parameter, since the +blah: method is expected to write an object of
type Bar*, a subtype of Foo*. For example:
int main (int argc, char const *argv[])
{
Foo *f;
[Nothing blah:&f];
return 0;
}
This works when -fobjc-arc is enabled, but otherwise, the following warning is
given:
warning: incompatible pointer types sending 'Foo **' to parameter of type
'Bar **' [-Wincompatible-pointer-types]
Note: the "in"/"out"/"inout" annotations have historically been part of
Distributed Objects, but still have meaning nowadays, as seen in Clang's ARC
documentation:
http://clang.llvm.org/docs/AutomaticReferenceCounting.html#passing-to-an-out-parameter-by-writeback
"A pass-by-writeback is evaluated as follows:
...
4. If the parameter is not an Objective-C method parameter marked out, then *p
is read, and the result is written into the temporary with primitive
semantics."
In my opinion these annotations/qualifiers should be enough for the compiler to
realize, in all cases, that passing a Foo** value to an "out Bar**" parameter
is completely valid. (This issue was inspired by the minor outrage against the
new Dropbox Obj-C API, which provides DBError, a subclass of NSError, and has
some DBError** writeback parameters. Dropbox did not mark these parameters
"out", but if they had, it should have not caused any problems to pass an
NSError**.)
--
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/20130714/7df3a52b/attachment.html>
More information about the llvm-bugs
mailing list