Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-24116

Build failure on MacOS on compiling the file lock/lock0lock.cc

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.6.0, 10.5
    • 10.5.9, 10.6.0
    • Compiling
    • None
    • compiler: Apple clang version 12.0.0 (clang-1200.0.32.21)

    Description

      Attempt to build MariaDB server on mac OS leads to compilation error:

      [ 61%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/lock/lock0lock.cc.o
      /Users/shulga/projects/mariadb/server-10.5/storage/innobase/lock/lock0lock.cc:5035:23: error: loop variable
      'page_id' of type 'const page_id_t' creates a copy from type 'const page_id_t'
      [-Werror,-Wrange-loop-analysis]
      for (const page_id_t page_id : pages) {
      ^
      /Users/shulga/projects/mariadb/server-10.5/storage/innobase/lock/lock0lock.cc:5035:7: note: use reference
      type 'const page_id_t &' to prevent copying
      for (const page_id_t page_id : pages) {
      ^~~~~~~~~~~~~~~~~~~~~~~~~
      &
      1 error generated.

      Attachments

        Activity

          shulga Dmitry Shulga created issue -

          I believe that following the suggestion of the compiler (note) would lead to a performance regression. Please have a look at the definition of page_id_t. Ever since MDEV-17491, the size of the object is 64 bits, which ought to be the same as the size of a pointer or a reference. Even on a 32-bit system, https://github.com/isocpp/CppCoreGuidelines/issues/1514 intentionally leaves this open in the C++ Core Guidelines: the size of the object would be exactly twice the size of a pointer or a reference.

          Would the warning go away if you simply removed the const? We do want to copy the 64-bit quantity there. (Also note that before 10.5, page_id_t wrapped two 32-bit members; in 10.5 it is wrapping one 64-bit member.)

          marko Marko Mäkelä added a comment - I believe that following the suggestion of the compiler ( note ) would lead to a performance regression. Please have a look at the definition of page_id_t . Ever since MDEV-17491 , the size of the object is 64 bits, which ought to be the same as the size of a pointer or a reference. Even on a 32-bit system, https://github.com/isocpp/CppCoreGuidelines/issues/1514 intentionally leaves this open in the C++ Core Guidelines: the size of the object would be exactly twice the size of a pointer or a reference. Would the warning go away if you simply removed the const ? We do want to copy the 64-bit quantity there. (Also note that before 10.5, page_id_t wrapped two 32-bit members; in 10.5 it is wrapping one 64-bit member.)
          shulga Dmitry Shulga made changes -
          Field Original Value New Value
          Fix Version/s 10.5.8 [ 25023 ]
          Fix Version/s 10.6.0 [ 24431 ]
          shulga Dmitry Shulga made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          shulga Dmitry Shulga made changes -
          Environment compiler: Apple clang version 12.0.0 (clang-1200.0.32.21)
          shulga Dmitry Shulga made changes -
          Affects Version/s 10.5 [ 23123 ]
          Affects Version/s 10.5.8 [ 25023 ]
          marko Marko Mäkelä made changes -
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Closed [ 6 ]
          marko Marko Mäkelä made changes -
          Fix Version/s 10.5.9 [ 25109 ]
          Fix Version/s 10.5.8 [ 25023 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 115397 ] MariaDB v4 [ 158541 ]

          People

            shulga Dmitry Shulga
            shulga Dmitry Shulga
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.