Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.6.0, 10.5
-
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
Field | Original Value | New Value |
---|---|---|
Fix Version/s | 10.5.8 [ 25023 ] | |
Fix Version/s | 10.6.0 [ 24431 ] |
Status | Open [ 1 ] | In Progress [ 3 ] |
Environment | compiler: Apple clang version 12.0.0 (clang-1200.0.32.21) |
Affects Version/s | 10.5 [ 23123 ] | |
Affects Version/s | 10.5.8 [ 25023 ] |
Resolution | Fixed [ 1 ] | |
Status | In Progress [ 3 ] | Closed [ 6 ] |
Fix Version/s | 10.5.9 [ 25109 ] | |
Fix Version/s | 10.5.8 [ 25023 ] |
Workflow | MariaDB v3 [ 115397 ] | MariaDB v4 [ 158541 ] |
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.)