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

unique_ptr should not be used for types that are not pointers

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 17
    • 17
    • tools
    • None
    • b13
    • windows

      I saw error during jpackage compilation with VS 2019 (16.9.0) as following (on Japanese locale):

      ```
      c:\progra~2\micros~2\2019\commun~1\vc\tools\msvc\1428~1.299\include\utility(604): error C2440: '=': '_Other' から '_Ty' に変換できません。
              with
              [
                  _Other=nullptr
              ]
              and
              [
                  _Ty=unsigned long
              ]
      c:\progra~2\micros~2\2019\commun~1\vc\tools\msvc\1428~1.299\include\utility(604): note: ネイティブの nullptr はブールに変換するか、または reinterpret_cast を使用して整数型に変換することのみが可能です
      c:\progra~2\micros~2\2019\commun~1\vc\tools\msvc\1428~1.299\include\memory(3423): note: コンパイル対象の関数 テンプレート インスタンス化 '_Ty std::exchange<_Ty2,nullptr>(_Ty &,_Other &&) noexcept(false)' のリファレンスを確認してください
              with
              [
                  _Ty=unsigned long,
                  _Ty2=unsigned long,
                  _Other=nullptr
              ]
      c:\progra~2\micros~2\2019\commun~1\vc\tools\msvc\1428~1.299\include\memory(3422): note: クラス テンプ レート メンバー関数 'unsigned long std::unique_ptr<MSIHANDLE,msi::MsiHandleDeleter>::release(void) noexcept' のコンパイル中
      d:\github-forked\jdk\src\jdk.jpackage\windows\native\common\MsiDb.cpp(237): note: コンパイル対象の関数 テンプレート インスタンス化 'unsigned long std::unique_ptr<MSIHANDLE,msi::MsiHandleDeleter>::release(void) noexcept' のリファレンスを確認してください
      d:\github-forked\jdk\src\jdk.jpackage\windows\native\common\MsiDb.h(119): note: コンパイル対象の クラ ス テンプレート インスタンス化 'std::unique_ptr<MSIHANDLE,msi::MsiHandleDeleter>' のリファレンスを確認してください
      ```

      `UniqueMSIHANDLE` is declared in MsiUtils.h as `unique_ptr` for `MSIHANDLE`. `MSIHANDLE` seems to be declared as synonym for `unsigned long`, not a pointer type.

          Loading...
          Uploaded image for project: 'JDK'
          1. JDK
          2. JDK-8263135

          unique_ptr should not be used for types that are not pointers

            • Icon: Bug Bug
            • Resolution: Fixed
            • Icon: P4 P4
            • 17
            • 17
            • tools
            • None
            • b13
            • windows

              I saw error during jpackage compilation with VS 2019 (16.9.0) as following (on Japanese locale):

              ```
              c:\progra~2\micros~2\2019\commun~1\vc\tools\msvc\1428~1.299\include\utility(604): error C2440: '=': '_Other' から '_Ty' に変換できません。
                      with
                      [
                          _Other=nullptr
                      ]
                      and
                      [
                          _Ty=unsigned long
                      ]
              c:\progra~2\micros~2\2019\commun~1\vc\tools\msvc\1428~1.299\include\utility(604): note: ネイティブの nullptr はブールに変換するか、または reinterpret_cast を使用して整数型に変換することのみが可能です
              c:\progra~2\micros~2\2019\commun~1\vc\tools\msvc\1428~1.299\include\memory(3423): note: コンパイル対象の関数 テンプレート インスタンス化 '_Ty std::exchange<_Ty2,nullptr>(_Ty &,_Other &&) noexcept(false)' のリファレンスを確認してください
                      with
                      [
                          _Ty=unsigned long,
                          _Ty2=unsigned long,
                          _Other=nullptr
                      ]
              c:\progra~2\micros~2\2019\commun~1\vc\tools\msvc\1428~1.299\include\memory(3422): note: クラス テンプ レート メンバー関数 'unsigned long std::unique_ptr<MSIHANDLE,msi::MsiHandleDeleter>::release(void) noexcept' のコンパイル中
              d:\github-forked\jdk\src\jdk.jpackage\windows\native\common\MsiDb.cpp(237): note: コンパイル対象の関数 テンプレート インスタンス化 'unsigned long std::unique_ptr<MSIHANDLE,msi::MsiHandleDeleter>::release(void) noexcept' のリファレンスを確認してください
              d:\github-forked\jdk\src\jdk.jpackage\windows\native\common\MsiDb.h(119): note: コンパイル対象の クラ ス テンプレート インスタンス化 'std::unique_ptr<MSIHANDLE,msi::MsiHandleDeleter>' のリファレンスを確認してください
              ```

              `UniqueMSIHANDLE` is declared in MsiUtils.h as `unique_ptr` for `MSIHANDLE`. `MSIHANDLE` seems to be declared as synonym for `unsigned long`, not a pointer type.

                    ysuenaga Yasumasa Suenaga
                    ysuenaga Yasumasa Suenaga
                    Votes:
                    0 Vote for this issue
                    Watchers:
                    4 Start watching this issue

                      Created:
                      Updated:
                      Resolved:

                        ysuenaga Yasumasa Suenaga
                        ysuenaga Yasumasa Suenaga
                        Votes:
                        0 Vote for this issue
                        Watchers:
                        4 Start watching this issue

                          Created:
                          Updated:
                          Resolved: