From owner-freebsd-current@FreeBSD.ORG Sat Jul 21 11:35:20 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 54462106564A; Sat, 21 Jul 2012 11:35:20 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) by mx1.freebsd.org (Postfix) with ESMTP id 0B5698FC14; Sat, 21 Jul 2012 11:35:20 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7:0:c4d4:5fc2:1faf:ed6] (unknown [IPv6:2001:7b8:3a7:0:c4d4:5fc2:1faf:ed6]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id B8CB95C37; Sat, 21 Jul 2012 13:35:18 +0200 (CEST) Message-ID: <500A93FE.1080700@FreeBSD.org> Date: Sat, 21 Jul 2012 13:35:26 +0200 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: Konstantin Belousov References: <50097BF0.9010103@FreeBSD.org> <20120720163352.GS2676@deviant.kiev.zoral.com.ua> <9EBB4101-3117-4FE0-AD08-1053423BECD6@FreeBSD.org> <20120720231604.GT2676@deviant.kiev.zoral.com.ua> In-Reply-To: <20120720231604.GT2676@deviant.kiev.zoral.com.ua> X-Enigmail-Version: 1.5a1pre Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Kim Culhan , freebsd-current@freebsd.org, David Chisnall Subject: Re: -current build failure X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Jul 2012 11:35:20 -0000 On 2012-07-21 01:16, Konstantin Belousov wrote: > On Fri, Jul 20, 2012 at 10:07:05PM +0100, David Chisnall wrote: >> On 20 Jul 2012, at 17:33, Konstantin Belousov wrote: >> >>> It is not related to dtrace at all, and indeed OFFSETOF_CURTHREAD is 0. >>> This is a bug in clang, we compile our kernel in freestanding environment. >> >> The copies of the C spec that I have do not differentiate between >> freestanding and hosted environments for the validity of dereferencing >> a pointer value of 0. Doing so is undefined in all cases and any >> standards-compliant compiler is quite at liberty to eat your dog in >> such situations - it is explicitly not guaranteed to read the memory at >> linear address 0 (this is undefined for at least two reasons that I can >> think of from the C spec, and probably more). > > Ok, I stand corrected. But the standard does not say what you claim > either. It only specifies that NULL pointer is unequal to any pointer > to object or function (implicitely saying that you can create a C object > or function pointer to which is equal to NULL). > > So, lets reformulate it other way: freestanding implementation in clang > has no use, at least for general purpose kernel. Especially ridiculous > is the fact that clang throws it hands for asm inline wanting to get > null address, on the machine with linearly addressable memory. Oh come on, that's just hyperbole. Everybody understands that directly dereferencing a NULL pointer is very unusual, in any environment. It's perfectly sane to warn about it. Is it such a big problem to simply insert a cast to tell the compiler you really want to do this, even if it is highly unusual?