RFR: 8073994: STATIC_ASSERT use of __LINE__ is wrong

David Holmes david.holmes at oracle.com
Thu Mar 5 21:01:22 UTC 2015


On 6/03/2015 2:55 AM, Kim Barrett wrote:
> On Mar 4, 2015, at 7:27 PM, David Holmes <david.holmes at oracle.com> wrote:
>>
>> Hi Kim,
>>
>> On 5/03/2015 6:14 AM, Kim Barrett wrote:
>>> Please review this small cleanup of the infrastructure underlying the
>>> STATIC_ASSERT macro.
>>>
>>> I will need a sponsor for this change.
>>>
>>> STATIC_ASSERT is using macro token splicing incorrectly to (attempt
>>> to) produce a unique type name.  Rather than fixing the splicing we
>>> note that the unique type name isn't actually needed.
>>>
>>> - If the assertion fails the type name never gets used at all.
>>
>> I can't figure out what this means if cond is false:
>>
>> typedef char STATIC_ASSERT_DUMMY_TYPE[ STATIC_ASSERT_FAILURE< (Cond) >::value ]
>
> We get a compiler error for attempting to access the non-existent
> STATIC_ASSERT_FAILURE<false>::value
> member before the compiler has any chance of complaining about a possible redefinition
> of STATIC_ASSERT_DUMMY_TYPE.
>

Doh! Hence why it is a compile-time checking idiom.

Thanks,
David


More information about the hotspot-dev mailing list