Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Feb 2012 06:31:28 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Alexander Best <arundel@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Dimitry Andric <dim@freebsd.org>
Subject:   Re: svn commit: r232074 - head/sys/cam/ctl
Message-ID:  <20120225061506.C2626@besplex.bde.org>
In-Reply-To: <20120224112224.GA13109@freebsd.org>
References:  <201202232134.q1NLYEq5024067@svn.freebsd.org> <20120224093807.GA88853@freebsd.org> <4F476FEA.1090004@FreeBSD.org> <20120224112224.GA13109@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 24 Feb 2012, Alexander Best wrote:

> On Fri Feb 24 12, Dimitry Andric wrote:
>> On 2012-02-24 10:38, Alexander Best wrote:
>>> which will turn all -Wformat-invalid-specifier and -Wformat-extra-args errors
>>> into warnings (because clang tot doesn't support -fformat-extensions)?
>>
>> It would be better to push our format extensions upstream, I think.
>> Though the option should probably be renamed to something else, e.g.
>> -ffreebsd-extensions, or such.

It is only for format extensions.  The idea is that a C compiler that
supports warning about unsupported printf formats must warn about
uses of format extensions (no matter whose they are) unless instructed
not to do so.  It seems excessive to have separate flags
-fbsd-format-extensions -ffreebsd-format-extensions
-fotherbsd-format-extensions -fgnu-format-extensions
-flinux-format-extensions ..., so I used a single flag.  If
-fbsd-format-extensions existed, then it would have only %b as an
extension.

Anyway, clang already supports -fformat-extensions.  The following
compiles with this, but fails messily without it:

% #include <stdio.h>
% 
% void
% foo(void)
% {
% 	printf("0x%b\n", 1, "\1foo");
% }

gcc (FreeBSD-gcc) complains about %#b, but clang doesn't.  I don't know
if %#b is valid, but it should be.

> i'm still confused regarding the actual politics regarding this change.
> everytime this comes up i get a different answer. the last one was that since
> the special printf format is only used for kernel code, the -fformat-extensions
> code within clang base shouldn't be pushed upstream.

Is it only the FreeBSD version of clang that has it?  Does FreeBSD has any
other significant local changes?  The flag should be push upstream, but
there are likely to always be OS-specific details.  For example, if %#b
is indeed invalid and someone fixes the kernel to support it, you don't
want to have to wait for the upstream sources to be synchronized before
using %#b.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120225061506.C2626>