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: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs