Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8073994

STATIC_ASSERT use of __LINE__ is wrong

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 9
    • hotspot
    • None
    • gc
    • b59
    • generic
    • generic

        The STATIC_ASSERT macro attempts to produce a unique type name by macro splicing with __LINE__. However, the way that's presently being done is incorrect:

          STATIC_ASSERT_FAILURE_ ## __LINE__

        doesn't expand __LINE__, so we get STATIC_ASSERT_FAILURE___LINE__.

        Doing this properly requires the use of a deferred concatenation macro, e.g.

        #define CONCAT(X, Y) X ## Y

        and

          CONCAT(STATIC_ASSERT_FAILURE_, __LINE__)

        However, there's a question as to whether we need the unique type name at all. If all the assertions succeed, the types are all the same.

        None of our compilers presently complains about multiple identical typedefs; but maybe we don't have the right warnings enabled. Also need to check whether that's standards conforming.

        Also need to look at the error messages for mix of pass and fail assertions, and multiple fail assertions.

              kbarrett Kim Barrett
              kbarrett Kim Barrett
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: