<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Objective-C method writeback parameter marked "out" does not allow passing more generic pointer type, unless -fobjc-arc is enabled"
href="http://llvm.org/bugs/show_bug.cgi?id=16626">16626</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Objective-C method writeback parameter marked "out" does not allow passing more generic pointer type, unless -fobjc-arc is enabled
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.3
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jtbandes@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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:
<a href="http://clang.llvm.org/docs/AutomaticReferenceCounting.html#passing-to-an-out-parameter-by-writeback">http://clang.llvm.org/docs/AutomaticReferenceCounting.html#passing-to-an-out-parameter-by-writeback</a>
"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**.)</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>