[LLVMbugs] [Bug 15484] New: Block types are not covariant in their return type and contravariant in their argument types with respect to C++ classes
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Mar 10 12:39:35 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=15484
Bug ID: 15484
Summary: Block types are not covariant in their return type and
contravariant in their argument types with respect to
C++ classes
Product: clang
Version: unspecified
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: jppellet at gmail.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
This bug is related to this StackOverflow question:
http://stackoverflow.com/questions/15312774/assigning-block-pointers-differences-between-objective-c-vs-c-classes
Imagine I have this simple Objective-C class hierarchy:
@interface Fruit : NSObject
@end
@interface Apple : Fruit
@end
Then I can write stuff like this:
Fruit *(^getFruit)();
Apple *(^getApple)();
getFruit = getApple;
This is all good and well — in Objective-C. Now let's try that in C++ or
Objective-C++, supposing we have these similar C++ classes:
class FruitCpp {};
class AppleCpp : public FruitCpp {};
class OrangeCpp : public FruitCpp {};
Sadly, these block assignments don't compile any more:
FruitCpp *(^getFruitCpp)();
AppleCpp *(^getAppleCpp)();
getFruitCpp = getAppleCpp; // error!
Why should it work for Objective-C classes and not C++ classes?
--
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/20130310/d5e13e00/attachment.html>
More information about the llvm-bugs
mailing list