Bug #5679

Too many arguments for format warnings on mingw32 build

Added by Heesob Park over 3 years ago. Updated over 2 years ago.

[ruby-core:41351]
Status:Closed
Priority:Normal
Assignee:Luis Lavena
ruby -v:- Backport:

Description

I can see the following warnings during mingw32 build.

gc.c: In function 'gc_profile_result':
gc.c:3581:4: warning: unknown conversion type character 'z' in format
gc.c:3581:4: warning: unknown conversion type character 'z' in format
gc.c:3581:4: warning: unknown conversion type character 'z' in format
gc.c:3581:4: warning: format '%30.20f' expects type 'double', but argument 5 has type 'unsigned int'
gc.c:3581:4: warning: too many arguments for format

transcode.c: In function 'str_transcode0':
transcode.c:2734:9: warning: unknown conversion type character 't' in format
transcode.c:2734:9: warning: too many arguments for format

iseq.c: In function 'insn_operand_intern':
iseq.c:826:50: warning: unknown conversion type character 't' in format
iseq.c:826:50: warning: too many arguments for format
iseq.c: In function 'rb_iseq_disasm_insn':
iseq.c:860:2: warning: unknown conversion type character 'z' in format
iseq.c:860:2: warning: format '%-16s' expects type 'char ', but argument 3 has type 'size_t'
iseq.c:860:2: warning: too many arguments for format
iseq.c:864:7: warning: unknown conversion type character 'z' in format
iseq.c:864:7: warning: format '%-16.
s' expects type 'char *', but argument 4 has type 'int'
iseq.c:864:7: warning: too many arguments for format

In file included from vm_exec.c:106:0,
from vm.c:25:
insns.def: In function 'vm_exec_core':
insns.def:1087:6: warning: unknown conversion type character 't' in format
insns.def:1087:6: warning: unknown conversion type character 't' in format
insns.def:1087:6: warning: too many arguments for format

rubyext.c: In function 'rb_syck_err_handler':
rubyext.c:687:12: warning: unknown conversion type character 't' in format
rubyext.c:687:12: warning: format '%s' expects type 'char *', but argument 5 has type 'int'
rubyext.c:687:12: warning: too many arguments for format

And I know these warnings are completely meaningless because Ruby uses it's own BSD_vfprintf implementaion.

Here is a patch of include/ruby/ruby.h for suppressing format warnings on mingw32

--- ruby.h 2011-11-28 14:21:11.000000000 +0900
+++ ruby.h.new 2011-11-28 14:23:01.000000000 +0900
@@ -37,7 +37,7 @@
# define NOINLINE(x) x
#endif

-#ifdef GNUC
+#if defined(GNUC) && !defined(MINGW32)
#define PRINTF_ARGS(decl, string_index, first_to_check) \
decl attribute((format(printf, string_index, first_to_check)))
#else

Associated revisions

Revision 33978
Added by Nobuyoshi Nakada about 3 years ago

  • configure.in (RUBY_WERROR_FLAG): append all warning flags which are enabled to compile, so that printf format modifiers properly fail. [Bug #5679]

Revision 33978
Added by Nobuyoshi Nakada about 3 years ago

  • configure.in (RUBY_WERROR_FLAG): append all warning flags which are enabled to compile, so that printf format modifiers properly fail. [Bug #5679]

History

#1 Updated by Motohiro KOSAKI over 3 years ago

  • ruby -v changed from ruby 2.0.0dev (2011-11-27) [i386-mingw32] to -

I can see the following warnings during mingw32 build.

gc.c: In function 'gc_profile_result':
gc.c:3581:4: warning: unknown conversion type character 'z' in format
gc.c:3581:4: warning: unknown conversion type character 'z' in format
gc.c:3581:4: warning: unknown conversion type character 'z' in format
gc.c:3581:4: warning: format '%30.20f' expects type 'double', but argument 5 has type 'unsigned int'
gc.c:3581:4: warning: too many arguments for format

Where does 'z' come from?

And I know these warnings are completely meaningless because Ruby uses it's own BSD_vfprintf implementaion.

Here is a patch of include/ruby/ruby.h for suppressing format warnings on mingw32

Your analysis doesn't have why mingw makes such annoying warnings.
And, in fact, 99% printf don't make such annoying warnings. So, it's
no good idea blindly suppressing.

#2 Updated by Luis Lavena over 3 years ago

On Mon, Nov 28, 2011 at 11:56 AM, KOSAKI Motohiro
kosaki.motohiro@gmail.com wrote:

I can see the following warnings during mingw32 build.

gc.c: In function 'gc_profile_result':
gc.c:3581:4: warning: unknown conversion type character 'z' in format
gc.c:3581:4: warning: unknown conversion type character 'z' in format
gc.c:3581:4: warning: unknown conversion type character 'z' in format
gc.c:3581:4: warning: format '%30.20f' expects type 'double', but argument 5 has type 'unsigned int'
gc.c:3581:4: warning: too many arguments for format

Where does 'z' come from?

PRI?SIZE from ruby.h

Anyhow, I think this is coming from printf implementation of MinGW:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id7768

And this:

http://mingw-users.1079350.n2.nabble.com/quot-z-quot-format-in-printf-statements-td5804407.html

Quoting:

"On 05.12.2010 6:36, Simson Garfinkel wrote:

Hi. Another porting question.

GCC on every platform I use has a %z format for size_t data. I even saw that on mingw with gcc 3.5 when run as a cross-compiler. But the %z format seems missing from the 4.x gcc running on Windows-hosted GCC. What should I do?

bloom.c:221:5: warning: unknown conversion type character 'z' in format

CFLAGS

#3 Updated by Motohiro KOSAKI over 3 years ago

Anyhow, I think this is coming from printf implementation of MinGW:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37768

And this:

http://mingw-users.1079350.n2.nabble.com/quot-z-quot-format-in-printf-statements-td5804407.html

Quoting:

"On 05.12.2010 6:36, Simson Garfinkel wrote:

Hi. Another porting question.

GCC on every platform I use has a %z format for size_t data. I even saw that on mingw with gcc 3.5 when run as a cross-compiler. But the %z format seems missing from the 4.x gcc running on Windows-hosted GCC. What should I do?

bloom.c:221:5: warning: unknown conversion type character 'z' in format

CFLAGS="-D_GNU_SOURCE=1" works for me. "

Great analisys!

So, I'm ok both Heesob's patch (but please add some comments) and CFLAGS change.

thank you.

#4 Updated by Motohiro KOSAKI about 3 years ago

  • Target version set to 2.0.0
  • Category set to core
  • Status changed from Open to Assigned
  • Assignee set to Luis Lavena

#5 Updated by Nobuyoshi Nakada about 3 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r33978.
Heesob, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • configure.in (RUBY_WERROR_FLAG): append all warning flags which are enabled to compile, so that printf format modifiers properly fail. [Bug #5679]

Also available in: Atom PDF