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

Potential compilation failure in istream.cpp:205 - loss of data on conversion

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • 23
    • hotspot
    • b10

      Detected by 32-bit Windows compiler:

      [2024-05-13T03:57:12,215Z] c:\sb\prod\1715572015\workspace\open\src\hotspot\share\utilities\istream.cpp(250): error C2220: the following warning is treated as an error
      [2024-05-13T03:57:12,215Z] c:\sb\prod\1715572015\workspace\open\src\hotspot\share\utilities\istream.cpp(250): warning C4267: '=': conversion from 'size_t' to 'char', possible loss of data

      The code line is:

          _line_ending = (int)(_next - end);

      where _next and end are size_t, and:

        char _line_ending; // one of {0,1,2} for "", "\n", "\r\n"

      There is clearly a loss of precision here: size_t -> int -> char, but the cast to int makes the error message unexpected.

      Simplest fix is to just make _line_ending an int.

            coleenp Coleen Phillimore
            dholmes David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: