[cfe-dev] Weak pointer support on 32-bit platforms

Aaron Ballman aaron at aaronballman.com
Mon May 12 07:52:48 PDT 2014


On Sun, May 11, 2014 at 7:37 PM, Alp Toker <alp at nuanti.com> wrote:
>
> On 12/05/2014 02:12, Hovik Melikyan wrote:
>>
>> Apologies, my bad, there is no bug. Turns out in certain circumstances
>> MinGW can redefine __attribute__ to do nothing, and as a result __weak
>> becomes either a simple "unsafe" ptr or for certain setups it may
>> become __strong.
>
>
> Hi Hovik,
>
> If that's the case there's still a bug in clang:
>
> The documentation describes __autoreleasing, __strong and __weak as
> attribute spellings but the implementation provides them as preprocessor
> macro definitions.
>
> I haven't examined why this is the case but one of the two could do with
> fixing (probably the implementation given that this is causing trouble on a
> supported platform). Aaron, any idea what's happened here?

__weak, __strong and __autoreleasing are not keywords, they are
preprocessor macros that result in an objc_gc attribute, which only
works with GNU-style attributes. There are some almost-keyword
versions (strong, weak, autoreleasing and several others) which are
contextual-ish keywords in ParseObjC, but they only relate to ObjC
properties.

If MinGW fiddles with __attribute__ in -fms-compatibility mode, that
would be problematic. But I'm not certain whether that would be
classified as a documentation bug, compiler bug or a MinGW bug (or
some combination thereof).

~Aaron



More information about the cfe-dev mailing list