Date: Mon, 21 May 2018 13:19:01 +0200 From: Dimitry Andric <dim@FreeBSD.org> To: Thomas Munro <munro@ip9.org> Cc: freebsd-hackers@freebsd.org Subject: Re: printf("%m") doesn't generate a warning -- shouldn't it? Message-ID: <BAD690AA-C51A-4125-8F23-B637758C8EB6@FreeBSD.org> In-Reply-To: <CADLWmXU__ZRaS=gg_Y18WYbJJgk2Rs065RhkYmAZCFY8mp1Wjg@mail.gmail.com> References: <CADLWmXU__ZRaS=gg_Y18WYbJJgk2Rs065RhkYmAZCFY8mp1Wjg@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_9681DDA2-FCE7-42EC-8128-C7000E8F487A Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii On 21 May 2018, at 04:38, Thomas Munro <munro@ip9.org> wrote: > > As discussed on the PostgreSQL[1] and NetBSD mailing lists[2][3], > syslog-like printf("%m") is a GNU extension that doesn't generate a > warning from Clang or GCC on other operating systems even though when > it doesn't actually work. That's because the __printf__ attribute > that our __printflike macro in /usr/include/stdio.h expands to > effectively means "like printf in glibc, allowing %m", not like POSIX > or our actual libc which just prints out "m" when it sees it. > > It'd sure be nice to get a compiler warning on FreeBSD when porting > software that uses that if it doesn't actually work (or ... to support > it). Please submit upstream bug(s) for clang and gcc. It turns out clang has a -Wformat-non-iso warning flag which should warn about this, but I can't get it to emit it: $ cat printf-m.c #include <stdio.h> int main(void) { printf("error: %m\n"); return 0; } $ clang -std=c99 -Wformat-non-iso -c printf-m.c <nothing> -Dimitry --Apple-Mail=_9681DDA2-FCE7-42EC-8128-C7000E8F487A Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.2 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCWwKrJQAKCRCwXqMKLiCW ozjeAJ4kfsJA3bcHbolMhV6Fi2shwU00IgCfff9mwhKHxENrR2HH8tJ78MyMU7o= =1T66 -----END PGP SIGNATURE----- --Apple-Mail=_9681DDA2-FCE7-42EC-8128-C7000E8F487A--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BAD690AA-C51A-4125-8F23-B637758C8EB6>