RFR: 8073994: STATIC_ASSERT use of __LINE__ is wrong
David Holmes
david.holmes at oracle.com
Thu Mar 5 00:27:54 UTC 2015
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 ]
> - If the assertion passes we're just redefining a typedef name with
> the same type, which is permitted (C++03 7.1.3 clause 3).
>
> So we just pick a dummy type name to always use.
Sounds reasonable.
David
-----
> CR:
> https://bugs.openjdk.java.net/browse/JDK-8073994
>
> Webrev:
> http://cr.openjdk.java.net/~kbarrett/8073994/webrev.00
>
> Testing:
> JPRT
> Local testing of assertion failures.
>
More information about the hotspot-dev
mailing list