Bootstrapping trunk with 32-bit-default on Mac OS X 10.11
(i386-apple-darwin15) fails:
/vol/gcc/src/hg/master/local/gcc/cobol/lexio.cc: In static member function 'static void cdftext::process_file(filespan_t, int, bool)':
/vol/gcc/src/hg/master/local/gcc/cobol/lexio.cc:1859:14: error: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'size_t' {aka 'long unsigned int'} [-Werror=format=]
1859 | dbgmsg("%s:%d: line " HOST_SIZE_T_PRINT_UNSIGNED ", opening %s on fd %d",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1860 | __func__, __LINE__,mfile.lineno(),
| ~~~~~~~~~~~~~~
| |
| size_t {aka long unsigned int}
In file included from /vol/gcc/src/hg/master/local/gcc/system.h:1244,
from /vol/gcc/src/hg/master/local/gcc/cobol/cobol-system.h:61,
from /vol/gcc/src/hg/master/local/gcc/cobol/lexio.cc:33:
/vol/gcc/src/hg/master/local/gcc/hwint.h:135:51: note: format string is defined here
135 | #define HOST_SIZE_T_PRINT_UNSIGNED "%" GCC_PRISZ "u"
| ~~~~~~~~~~~~~~^
| |
| unsigned int
| %" GCC_PRISZ "lu
On Darwin, size_t is always long unsigned int. However, unsigned int
and long unsigned int are both 32-bit, so hwint.h selects %u for the
format. As documented there, the arg needs to be cast to fmt_size_t to
avoid the error.
This isn't an issue on other 32-bit platforms like Solaris/i386 or
Linux/i686 since they use unsigned int for size_t.
/vol/gcc/src/hg/master/local/gcc/cobol/parse.y: In function 'int yyparse()':
/vol/gcc/src/hg/master/local/gcc/cobol/parse.y:10215:36: error: format '%zu' expects argument of type 'size_t', but argument 4 has type 'int' [-Werror=format=]
10215 | error_msg(loc, "FUNCTION %qs has "
| ^~~~~~~~~~~~~~~~~~~
10216 | "inconsistent parameter type %zu (%qs)",
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10217 | keyword_str($1), p - args.data(), name_of(p->field) );
| ~~~~~~~~~~~~~~~
| |
| int
The arg (p - args.data())) is ptrdiff_t (int on 32-bit Darwin), while
the %zu format expect size_t (long unsigned int). The patch therefore
casts the ptrdiff_t arg to long and prints it as such.
There are two more instances of the same problem:
/vol/gcc/src/hg/master/local/gcc/cobol/util.cc: In member function 'void cbl_field_t::report_invalid_initial_value(const YYLTYPE&) const':
/vol/gcc/src/hg/master/local/gcc/cobol/util.cc:905:80: error: format '%zu' expects argument of type 'size_t', but argument 6 has type 'int' [-Werror=format=]
905 | error_msg(loc, "%s cannot represent VALUE %qs exactly (max %c%zu)",
| ~~^
| |
| long unsigned int
| %u
906 | name, data.initial, '.', pend - p);
| ~~~~~~~~
| |
| int
In file included from /vol/gcc/src/hg/master/local/gcc/cobol/scan.l:48:
/vol/gcc/src/hg/master/local/gcc/cobol/scan_ante.h: In function 'int numstr_of(const char*, radix_t)':
/vol/gcc/src/hg/master/local/gcc/cobol/scan_ante.h:152:25: error: format '%zu' expects argument of type 'size_t', but argument 4 has type 'int' [-Werror=format=]
152 | error_msg(yylloc, "significand of %s has more than 36 digits (%zu)", input, nx);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
| |
| int
Fixed in the same way.
Bootstrapped without regressions on i386-apple-darwin15,
x86_64-apple-darwin, i386-pc-solaris2.11, amd64-pc-solaris2.11,
i686-pc-linux-gnu, and x86_64-pc-linux-gnu.