Bug #71624 printf size_t results in a fatal warning in 32-bit debug builds
Submitted: 7 Feb 2014 13:12 Modified: 7 Feb 2014 18:40
Reporter: Laurynas Biveinis Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S6 (Debug Builds)
Version:5.6.16 OS:Any
Assigned to: CPU Architecture:Any
Tags: debug, printf, regression, size_t, warning

[7 Feb 2014 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.
[7 Feb 2014 18:40] Sveta Smirnova
Thank you for the report.

This is fixed in current development sources. verify.size() explicitly casted to unlint