From owner-freebsd-hackers@freebsd.org Mon May 21 11:19:08 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BA7F7EED454 for ; Mon, 21 May 2018 11:19:08 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 491C5791F7 for ; Mon, 21 May 2018 11:19:08 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from coleburn.home.andric.com (coleburn.home.andric.com [192.168.0.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 80C99F072; Mon, 21 May 2018 13:19:06 +0200 (CEST) From: Dimitry Andric Message-Id: Content-Type: multipart/signed; boundary="Apple-Mail=_9681DDA2-FCE7-42EC-8128-C7000E8F487A"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 11.3 \(3445.6.18\)) Subject: Re: printf("%m") doesn't generate a warning -- shouldn't it? Date: Mon, 21 May 2018 13:19:01 +0200 In-Reply-To: Cc: freebsd-hackers@freebsd.org To: Thomas Munro References: X-Mailer: Apple Mail (2.3445.6.18) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 May 2018 11:19:08 -0000 --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 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 int main(void) { printf("error: %m\n"); return 0; } $ clang -std=c99 -Wformat-non-iso -c printf-m.c -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--