[cfe-dev] Objective-C++11 literal types
John McCall
rjmccall at apple.com
Thu Dec 1 20:09:00 PST 2011
On Dec 1, 2011, at 4:23 PM, Richard Smith wrote:
> I was surprised to find this in AST::Type::isLiteralType:
>
> // Objective-C lifetime types are not literal types.
> if (BaseTy->isObjCRetainableType())
> return false;
>
> This is strange, because we do support constant expression evaluation of
> Objective-C lifetime types (outside C++11).
>
> So which is correct? Should lifetime types be permitted as literal types, or
> should they not be permitted as the type of globals in (Objective-)C? Or is
> there some reason why C++11 should treat them differently from other
> languages?
I don't know the reasoning for that change, but I would assume it's
supposed to apply to ownership-qualified types under ARC, i.e.
types with a non-trivial ObjCLifetime qualifier, because such types
generally require extra operations which need to be performed at
runtime. However, I don't know that that's actually correct, because
any object of such a type that can be constant-evaluated must also
be statically allocated, which means that retains and releases can
be completely ignored. That might be a lot of complexity to get right,
though.
John.
More information about the cfe-dev
mailing list