printf size_t results in a fatal warning in 32-bit debug builds

Bug #1277505 reported by Laurynas Biveinis
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Server
Unknown
Unknown
Percona Server moved to https://jira.percona.com/projects/PS
Fix Released
High
Laurynas Biveinis
5.6
Fix Released
High
Laurynas Biveinis

Bug Description

http://bugs.mysql.com/bug.php?id=71624:

[7 Feb 13:12] Laurynas Biveinis

Description:
5.6.16 fails to build with -DWITH_DEBUG=ON because:

on Ubuntu Quantal, 32 bits:

/home/jenkins/workspace/mysql-5.6-trunk/BUILD_TYPE/debug/Host/ubuntu-quantal-32bit/storage/innobase/fil/fil0fil.cc: In function ‘bool fil_user_tablespace_find_space_id(fsp_open_info*)’:
/home/jenkins/workspace/mysql-5.6-trunk/BUILD_TYPE/debug/Host/ubuntu-quantal-32bit/storage/innobase/fil/fil0fil.cc:4106:41: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘std::map<long unsigned int, long unsigned int>::size_type {aka unsigned int}’ [-Werror=format]

on CentOS 6, 32 bits

cc1plus: warnings being treated as errors
/home/jenkins/workspace/mysql-5.6-trunk/BUILD_TYPE/debug/Host/centos6-32/storage/innobase/fil/fil0fil.cc: In function 'bool fil_user_tablespace_find_space_id(fsp_open_info*)':
/home/jenkins/workspace/mysql-5.6-trunk/BUILD_TYPE/debug/Host/centos6-32/storage/innobase/fil/fil0fil.cc:4106: error: format '%lu' expects type 'long unsigned int', but argument 4 has type 'size_t'
make[2]: *** [storage/innobase/CMakeFiles/innobase.dir/fil/fil0fil.cc.o] Error 1

Code in question is

  ib_logf(IB_LOG_LEVEL_INFO, "Page size: %lu, Possible space_id "
   "count:%lu", page_size, verify.size());

"%lu" is not a portable way to print size_t.

Regression introduced in rev 5703.

How to repeat:
Configure an build on a 32 bit host with -DWITH_DEBUG=ON.

Suggested fix:
AFAIK there is no portable printf format specifier for size_t. One has to cast size_t to something wide, e.g. ib_uint64_t and use UINT64PF.

Related branches

tags: added: innodb upstream
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-760

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.