Send MinGW-Notify mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.osdn.me/mailman/listinfo/mingw-notify
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of MinGW-Notify digest..."


Please do not reply to this notification; the sender address is unable to 
accept incoming e-mail.  If you wish to unsubscribe you can do so at 
https://lists.osdn.me/mailman/listinfo/mingw-notify.



Today's Topics:

   1. [mingw] #43663: %zd and %td support in attribute format
      printf (MinGW Notification List)
   2. [mingw] #43663: %zd and %td support in attribute format
      printf (MinGW Notification List)


----------------------------------------------------------------------

Message: 1
Date: Sun, 23 Jan 2022 12:41:24 +0000
From: MinGW Notification List <[email protected]>
To: OSDN Ticket System <[email protected]>
Subject: [MinGW-Notify] [mingw] #43663: %zd and %td support in
        attribute format printf
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=UTF-8

#43663: %zd and %td support in attribute format printf

  Open Date: 2022-01-20 10:09
Last Update: 2022-01-23 12:41

URL for this Ticket:
    https://osdn.net//projects/mingw/ticket/43663
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=3917&tid=43663

---------------------------------------------------------------------

Last Changes/Comment on this Ticket:
2022-01-23 12:41 Updated by: keith

Comment:

Thank you for this exemplary issue report; I do so wish that all ticket 
submissions could be so diligently formatted, comprehensively detailed, and 
complemented by such a well specified, compact, yet complete test case.
I can confirm that your issue is reproduced by my own mingw32-gcc 
cross-compiler suite, (which FWIW, is the self-same implementation that I used 
to create the official MinGW.OSDN distribution of GCC-9.2.0):
$ mingw32-gcc -v -Wall -fsyntax-only a.c
Using built-in specs.
COLLECT_GCC=mingw32-gcc
COLLECT_LTO_WRAPPER=/home/keith/mingw32-gcc-9.2.0/bin/../libexec/gcc/mingw32/9.2.0/lto-wrapper
Target: mingw32
Configured with: ../src/gcc-9.2.0/configure --target=mingw32 
--disable-win32-registry --with-arch=i586 --with-tune=generic --enable-static 
--enable-shared --enable-threads 
--enable-languages=c,c++,objc,obj-c++,fortran,ada --with-dwarf2 
--disable-sjlj-exceptions --enable-version-specific-runtime-libs 
--enable-libgomp --disable-libvtv --with-libiconv-prefix=/mingw 
--with-libintl-prefix=/mingw --enable-libstdcxx-debug 
--disable-build-format-warnings --prefix=/home/keith/mingw32 
--with-sysroot=/home/keith/mingw32 --disable-nls --with-pkgversion='MinGW.org 
Cross-GCC Build-20200531-1'
Thread model: win32
gcc version 9.2.0 (MinGW.org Cross-GCC Build-20200531-1) 
COLLECT_GCC_OPTIONS='-v' '-Wall' '-fsyntax-only' '-mtune=generic' '-march=i586'
 /home/keith/mingw32-gcc-9.2.0/bin/../libexec/gcc/mingw32/9.2.0/cc1 -quiet -v 
-iprefix /home/keith/mingw32-gcc-9.2.0/bin/../lib/gcc/mingw32/9.2.0/ -isysroot 
/home/keith/mingw32-gcc-9.2.0/bin/../../mingw32 a.c -quiet -dumpbase a.c 
-mtune=generic -march=i586 -auxbase a -Wall -version -fsyntax-only -o /dev/null
GNU C17 (MinGW.org Cross-GCC Build-20200531-1) version 9.2.0 (mingw32)
        compiled by GNU C version 9.3.0, GMP version 6.1.2, MPFR version 4.0.2, 
MPC version 1.1.0, isl version isl-0.21-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory 
"/home/keith/mingw32-gcc-9.2.0/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/include"
ignoring duplicate directory 
"/home/keith/mingw32-gcc-9.2.0/bin/../lib/gcc/../../lib/gcc/mingw32/9.2.0/include"
ignoring nonexistent directory 
"/home/keith/mingw32-gcc-9.2.0/bin/../../mingw32/usr/local/include"
ignoring duplicate directory 
"/home/keith/mingw32-gcc-9.2.0/bin/../lib/gcc/../../lib/gcc/mingw32/9.2.0/include-fixed"
ignoring nonexistent directory 
"/home/keith/mingw32-gcc-9.2.0/bin/../lib/gcc/../../lib/gcc/mingw32/9.2.0/../../../../mingw32/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/keith/mingw32-gcc-9.2.0/bin/../lib/gcc/mingw32/9.2.0/include
 /home/keith/mingw32-gcc-9.2.0/bin/../lib/gcc/mingw32/9.2.0/include-fixed
 /home/keith/mingw32-gcc-9.2.0/bin/../../mingw32/mingw/include
End of search list.
GNU C17 (MinGW.org Cross-GCC Build-20200531-1) version 9.2.0 (mingw32)
        compiled by GNU C version 9.3.0, GMP version 6.1.2, MPFR version 4.0.2, 
MPC version 1.1.0, isl version isl-0.21-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 43d95314bbda36f2d474b814015ff720
a.c: In function 'main':
a.c:8:16: warning: unknown conversion type character 'z' in format [-Wformat=]
    8 |   return foo("%zd\n", f);
      |                ^
a.c:8:14: warning: too many arguments for format [-Wformat-extra-args]
    8 |   return foo("%zd\n", f);
      |              ^~~~~~~
COMPILER_PATH=/home/keith/mingw32-gcc-9.2.0/bin/../libexec/gcc/mingw32/9.2.0/:/home/keith/mingw32-gcc-9.2.0/bin/../libexec/gcc/:/home/keith/mingw32-gcc-9.2.0/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/
LIBRARY_PATH=/home/keith/mingw32-gcc-9.2.0/bin/../lib/gcc/mingw32/9.2.0/:/home/keith/mingw32-gcc-9.2.0/bin/../lib/gcc/:/home/keith/mingw32-gcc-9.2.0/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/lib/:/home/keith/mingw32-gcc-9.2.0/bin/../../mingw32/lib/
COLLECT_GCC_OPTIONS='-v' '-Wall' '-fsyntax-only' '-mtune=generic' '-march=i586'
However, I do feel obliged to point out that the compilers, which you are 
using, are not products of our MinGW.OSDN Project, and we are unable to support 
them; consequently, while we may be able to offer generic advice, we can offer 
no guarantees that such advice will actually apply, in your specific use case.  
Furthermore, I would like to challenge this assertion, in your original 
submission:
MS compiler supports %zd as the preferred way to print size_t values 
While this may be true of recent versions of the MS compiler, (and likely 
requires that the application be linked with Microsoft's non-free Universal C 
Runtime Library, or any the non-free runtime libraries which are distributed as 
components of the MSVC suite itself), it is not true in the case of 
applications which are linked (as MinGW applications must be) with MSVCRT.DLL; 
(note that, although itself technically non-free, MSVCRT.DLL is distributed as 
a fundamental OS component, and is sufficiently self-contained to let us use it 
under the GPL exemption for such OS components; unfortunately, although AIUI 
the UCRT is also provided as an OS component, it is not self-contained, and its 
dependencies, which are not so distributed, render it fundamentally useless in 
this context).
Now, I realize that I have not yet actually addressed the issue, which you have 
raised; in the interests of keeping follow-up comments at a manageable size, I 
will defer further discussion to a later comment.

---------------------------------------------------------------------
Ticket Status:

      Reporter: eric_pouech
         Owner: (None)
          Type: Issues
        Status: Open
      Priority: 5 - Medium
     MileStone: (None)
     Component: (None)
      Severity: 5 - Medium
    Resolution: None
---------------------------------------------------------------------

Ticket details:

sample a.c
#include <stddef.h>
int foo(const char*,...) __attribute__((format(printf, 1, 2)));

int main(void)
{
        size_t f = sizeof(size_t);
        return foo("%zd\n", f);
}
this simple program, compiled with -Wall warns about unsupported %zd
$ x86_64-w64-mingw32-gcc a.c -Wall 
a.c: In function 'main':
a.c:7:22: warning: unknown conversion type character 'z' in format [-Wformat=]
    7 |         return foo("%zd\n", f);
      |                      ^
$ i686-w64-mingw32-gcc a.c -Wall 
a.c: In function 'main':
a.c:7:22: warning: unknown conversion type character 'z' in format [-Wformat=]
    7 |         return foo("%zd\n", f);
      |                      ^
whereas gcc compiles the snipnet just fine
version info$ x86_64-w64-mingw32-gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/x86_64-w64-mingw32-gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-w64-mingw32/11.2.1/lto-wrapper
Target: x86_64-w64-mingw32
Configured with: ../configure --prefix=/usr --bindir=/usr/bin 
--includedir=/usr/include --mandir=/usr/share/man --infodir=/usr/share/info 
--datadir=/usr/share --build=x86_64-redhat-linux-gnu 
--host=x86_64-redhat-linux-gnu --with-gnu-as --with-gnu-ld --verbose 
--without-newlib --disable-multilib --disable-plugin --with-system-zlib 
--disable-nls --without-included-gettext --disable-win32-registry 
--enable-languages=c,c++,objc,obj-c++,fortran 
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-threads=posix 
--with-isl --enable-libgomp --target=x86_64-w64-mingw32 
--with-sysroot=/usr/x86_64-w64-mingw32/sys-root 
--with-gxx-include-dir=/usr/x86_64-w64-mingw32/sys-root/mingw/include/c++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.1 20210728 (Fedora MinGW 11.2.1-3.fc35) (GCC) 
version info$ i686-w64-mingw32-gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/i686-w64-mingw32-gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-w64-mingw32/11.2.1/lto-wrapper
Target: i686-w64-mingw32
Configured with: ../configure --prefix=/usr --bindir=/usr/bin 
--includedir=/usr/include --mandir=/usr/share/man --infodir=/usr/share/info 
--datadir=/usr/share --build=x86_64-redhat-linux-gnu 
--host=x86_64-redhat-linux-gnu --with-gnu-as --with-gnu-ld --verbose 
--without-newlib --disable-multilib --disable-plugin --with-system-zlib 
--disable-nls --without-included-gettext --disable-win32-registry 
--enable-languages=c,c++,objc,obj-c++,fortran 
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-threads=posix 
--with-isl --enable-libgomp --target=i686-w64-mingw32 
--with-sysroot=/usr/i686-w64-mingw32/sys-root 
--with-gxx-include-dir=/usr/i686-w64-mingw32/sys-root/mingw/include/c++ 
--disable-sjlj-exceptions --with-dwarf2
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.1 20210728 (Fedora MinGW 11.2.1-3.fc35) (GCC) 
MS compiler supports %zd as the preferred way to print size_t values
(didn't included in the tests, but %td for ptrdiff_t suffers from the same 
issues)

-- 
Ticket information of MinGW - Minimalist GNU for Windows project
MinGW - Minimalist GNU for Windows Project is hosted on OSDN

Project URL: https://osdn.net/projects/mingw/
OSDN: https://osdn.net

URL for this Ticket:
    https://osdn.net/projects/mingw/ticket/43663
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=3917&tid=43663


------------------------------

Message: 2
Date: Sun, 23 Jan 2022 21:15:56 +0000
From: MinGW Notification List <[email protected]>
To: OSDN Ticket System <[email protected]>
Subject: [MinGW-Notify] [mingw] #43663: %zd and %td support in
        attribute format printf
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=UTF-8

#43663: %zd and %td support in attribute format printf

  Open Date: 2022-01-20 10:09
Last Update: 2022-01-23 21:15

URL for this Ticket:
    https://osdn.net//projects/mingw/ticket/43663
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=3917&tid=43663

---------------------------------------------------------------------

Last Changes/Comment on this Ticket:
2022-01-23 21:15 Updated by: keith

Comment:

In my earlier comment, I indicated that I observe the same behaviour as that 
described in the original report; for reference, here is the compiler output, 
without the added noise of GCC version, and configuration information:
$ mingw32-gcc -Wall -fsyntax-only a.c
a.c: In function 'main':
a.c:8:16: warning: unknown conversion type character 'z' in format [-Wformat=]
    8 |   return foo("%zd\n", f);
      |                ^
a.c:8:14: warning: too many arguments for format [-Wformat-extra-args]
    8 |   return foo("%zd\n", f);
      |              ^~~~~~~
In addition to this, I also dropped a hint — you may, or may not have noticed 
it — as to why this may actually be considered to be correct behaviour. Unlike 
Microsoft's compilers — which use non-free runtime libraries, none of which are 
legally redistributable without purchase of a Microsoft developer's licence — 
MinGW compilers produce applications which are linked with MSVCRT.DLL. Although 
also proprietary, Microsoft distribute this as a component of the Windows 
operating system, so no redistribution is necessary; however, the stdio 
implementation in MSVCRT.DLL — and specifically its printf() family of 
functions — does not support the "%zd" or "%td" format specifications.  Since 
the MinGW compilers — at least those which we distribute — use the MSVCRT.DLL 
printf() implementation, by default, it seems reasonable that -Wformat should 
warn that these format specifications are unsupported.
Of course, default behaviour isn't always appropriate ... and it probably 
isn't, in your particular use case. The intent of my emphasis — of by default — 
in the preceding paragraph, is to indicate that we are not simply stuck with 
default behaviour; there are techniques, which we may adopt to work around this 
issue, and which I will address in a further follow-up comment.

---------------------------------------------------------------------
Ticket Status:

      Reporter: eric_pouech
         Owner: (None)
          Type: Issues
        Status: Open
      Priority: 5 - Medium
     MileStone: (None)
     Component: (None)
      Severity: 5 - Medium
    Resolution: None
---------------------------------------------------------------------

Ticket details:

sample a.c
#include <stddef.h>
int foo(const char*,...) __attribute__((format(printf, 1, 2)));

int main(void)
{
        size_t f = sizeof(size_t);
        return foo("%zd\n", f);
}
this simple program, compiled with -Wall warns about unsupported %zd
$ x86_64-w64-mingw32-gcc a.c -Wall 
a.c: In function 'main':
a.c:7:22: warning: unknown conversion type character 'z' in format [-Wformat=]
    7 |         return foo("%zd\n", f);
      |                      ^
$ i686-w64-mingw32-gcc a.c -Wall 
a.c: In function 'main':
a.c:7:22: warning: unknown conversion type character 'z' in format [-Wformat=]
    7 |         return foo("%zd\n", f);
      |                      ^
whereas gcc compiles the snipnet just fine
version info$ x86_64-w64-mingw32-gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/x86_64-w64-mingw32-gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-w64-mingw32/11.2.1/lto-wrapper
Target: x86_64-w64-mingw32
Configured with: ../configure --prefix=/usr --bindir=/usr/bin 
--includedir=/usr/include --mandir=/usr/share/man --infodir=/usr/share/info 
--datadir=/usr/share --build=x86_64-redhat-linux-gnu 
--host=x86_64-redhat-linux-gnu --with-gnu-as --with-gnu-ld --verbose 
--without-newlib --disable-multilib --disable-plugin --with-system-zlib 
--disable-nls --without-included-gettext --disable-win32-registry 
--enable-languages=c,c++,objc,obj-c++,fortran 
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-threads=posix 
--with-isl --enable-libgomp --target=x86_64-w64-mingw32 
--with-sysroot=/usr/x86_64-w64-mingw32/sys-root 
--with-gxx-include-dir=/usr/x86_64-w64-mingw32/sys-root/mingw/include/c++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.1 20210728 (Fedora MinGW 11.2.1-3.fc35) (GCC) 
version info$ i686-w64-mingw32-gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/i686-w64-mingw32-gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-w64-mingw32/11.2.1/lto-wrapper
Target: i686-w64-mingw32
Configured with: ../configure --prefix=/usr --bindir=/usr/bin 
--includedir=/usr/include --mandir=/usr/share/man --infodir=/usr/share/info 
--datadir=/usr/share --build=x86_64-redhat-linux-gnu 
--host=x86_64-redhat-linux-gnu --with-gnu-as --with-gnu-ld --verbose 
--without-newlib --disable-multilib --disable-plugin --with-system-zlib 
--disable-nls --without-included-gettext --disable-win32-registry 
--enable-languages=c,c++,objc,obj-c++,fortran 
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-threads=posix 
--with-isl --enable-libgomp --target=i686-w64-mingw32 
--with-sysroot=/usr/i686-w64-mingw32/sys-root 
--with-gxx-include-dir=/usr/i686-w64-mingw32/sys-root/mingw/include/c++ 
--disable-sjlj-exceptions --with-dwarf2
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.1 20210728 (Fedora MinGW 11.2.1-3.fc35) (GCC) 
MS compiler supports %zd as the preferred way to print size_t values
(didn't included in the tests, but %td for ptrdiff_t suffers from the same 
issues)

-- 
Ticket information of MinGW - Minimalist GNU for Windows project
MinGW - Minimalist GNU for Windows Project is hosted on OSDN

Project URL: https://osdn.net/projects/mingw/
OSDN: https://osdn.net

URL for this Ticket:
    https://osdn.net/projects/mingw/ticket/43663
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=3917&tid=43663


------------------------------

Subject: Digest Footer

_______________________________________________
MinGW-Notify mailing list
[email protected]
https://lists.osdn.me/mailman/listinfo/mingw-notify


------------------------------

End of MinGW-Notify Digest, Vol 49, Issue 3
*******************************************

Reply via email to