Description:
A coding technique used by some MySQL programs leads to compilation warnings on 32-bit platforms. A trivial recoding can eliminate the warnings.
The following technique produces "shift count greater than width of type" error messages (on the right-shift operator):
if (sizeof (off_t) > 4) {
*size = (ulint)(offs & 0xFFFFFFFFUL);
*size_high = (ulint)(offs >> 32);
} else {
*size = (ulint) offs;
*size_high = 0;
}
Since only one of these two cases can possibly arise on any given platform and since the appropriate case can be determined at compile-time, the following recoding eliminates the warning.
#if SIZEOF_OFF_T > 4
/* same as above */
#else
/* same as above */
#endif
Error messages:
/ssp/mysql/rebuild.2.0/mysql/storage/innobase/os/os0file.c: In function `os_file_get_size':
/ssp/mysql/rebuild.2.0/mysql/storage/innobase/os/os0file.c:1715: warning: right shift count >= width of type
/ssp/mysql/rebuild.2.0/mysql/storage/innobase/os/os0file.c: In function `os_file_pread':
/ssp/mysql/rebuild.2.0/mysql/storage/innobase/os/os0file.c:2026: warning: left shift count >= width of type
/ssp/mysql/rebuild.2.0/mysql/storage/innobase/os/os0file.c: In function `os_file_pwrite':
/ssp/mysql/rebuild.2.0/mysql/storage/innobase/os/os0file.c:2111: warning: left shift count >= width of type
How to repeat:
I ran into this problem building MySQL 5.1.48 on the Stratus OpenVOS operating system, Release 17.1. I have verified that the code in question still exists in MySQL 5.6.2-m5. We are using gcc version 3.4.6, with the compilation warnings set to the MySQL default values (no extra -W flags have been specified).
I will attach a patch file to this bug report that corrects the errors that I encountered.
In theory, you should be able to reproduce this gcc warning message by simply building MySQL on a 32-bit platform.
Suggested fix:
I will attach a patch file that is valid for mysql-5.6.2-m5. It is based on identical changes that I made to mysql 5.1.48.
Description: A coding technique used by some MySQL programs leads to compilation warnings on 32-bit platforms. A trivial recoding can eliminate the warnings. The following technique produces "shift count greater than width of type" error messages (on the right-shift operator): if (sizeof (off_t) > 4) { *size = (ulint)(offs & 0xFFFFFFFFUL); *size_high = (ulint)(offs >> 32); } else { *size = (ulint) offs; *size_high = 0; } Since only one of these two cases can possibly arise on any given platform and since the appropriate case can be determined at compile-time, the following recoding eliminates the warning. #if SIZEOF_OFF_T > 4 /* same as above */ #else /* same as above */ #endif Error messages: /ssp/mysql/rebuild.2.0/mysql/storage/innobase/os/os0file.c: In function `os_file_get_size': /ssp/mysql/rebuild.2.0/mysql/storage/innobase/os/os0file.c:1715: warning: right shift count >= width of type /ssp/mysql/rebuild.2.0/mysql/storage/innobase/os/os0file.c: In function `os_file_pread': /ssp/mysql/rebuild.2.0/mysql/storage/innobase/os/os0file.c:2026: warning: left shift count >= width of type /ssp/mysql/rebuild.2.0/mysql/storage/innobase/os/os0file.c: In function `os_file_pwrite': /ssp/mysql/rebuild.2.0/mysql/storage/innobase/os/os0file.c:2111: warning: left shift count >= width of type How to repeat: I ran into this problem building MySQL 5.1.48 on the Stratus OpenVOS operating system, Release 17.1. I have verified that the code in question still exists in MySQL 5.6.2-m5. We are using gcc version 3.4.6, with the compilation warnings set to the MySQL default values (no extra -W flags have been specified). I will attach a patch file to this bug report that corrects the errors that I encountered. In theory, you should be able to reproduce this gcc warning message by simply building MySQL on a 32-bit platform. Suggested fix: I will attach a patch file that is valid for mysql-5.6.2-m5. It is based on identical changes that I made to mysql 5.1.48.