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

checked_cast doesn't properly check some cases

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Unresolved
    • P4
    • tbd
    • 22
    • hotspot

    Description

      The round-trip test currently used by checked_cast doesn't work in some cases. For example:

      checked_cast<uint>(SIZE_MAX) => error as expected
      checked_cast<int>(SIZE_MAX) => no error?

      The problem is that SIZE_MAX successfully round-trips because
      static_cast<size_t>(-1) => SIZE_MAX
      due to sign extension when promoting the type.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated: