From owner-svn-src-head@FreeBSD.ORG Tue Nov 12 09:02:37 2013 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9ECC13B6; Tue, 12 Nov 2013 09:02:37 +0000 (UTC) Received: from mail109.syd.optusnet.com.au (mail109.syd.optusnet.com.au [211.29.132.80]) by mx1.freebsd.org (Postfix) with ESMTP id 511692B18; Tue, 12 Nov 2013 09:02:36 +0000 (UTC) Received: from c122-106-156-23.carlnfd1.nsw.optusnet.com.au (c122-106-156-23.carlnfd1.nsw.optusnet.com.au [122.106.156.23]) by mail109.syd.optusnet.com.au (Postfix) with ESMTPS id DCF55D62B83; Tue, 12 Nov 2013 20:02:26 +1100 (EST) Date: Tue, 12 Nov 2013 20:02:25 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Dimitry Andric Subject: Re: svn commit: r258016 - head/sys/i386/conf In-Reply-To: <201311112116.rABLGulr021023@svn.freebsd.org> Message-ID: <20131112190919.D1059@besplex.bde.org> References: <201311112116.rABLGulr021023@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=bpB1Wiqi c=1 sm=1 tr=0 a=ebeQFi2P/qHVC0Yw9JDJ4g==:117 a=PO7r1zJSAAAA:8 a=2GcSZCsbw90A:10 a=kj9zAlcOel0A:10 a=JzwRw_2MAAAA:8 a=p0uFSuVCeJIA:10 a=utdg7qceU81CC6U69F8A:9 a=CjuIK1q_8ugA:10 Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Nov 2013 09:02:37 -0000 On Mon, 11 Nov 2013, Dimitry Andric wrote: > Log: > Disable building the ctl module for the i386 XEN kernel configuration > for now, since it causes gcc warnings about casting 64 bit bus_addr_t's > to 32 bit pointers, and vice versa. Why not disable clang, since it is incompatible? :-)/2 The warning is needed because detecting invalid conversions between pointers and integers is difficult without it. You have to cast to prevent errors, but it is too easy to use a cast that doesn't work. Similarly for -Wcast-qual, except an error for it is less needed. This is broken in clang too: void *p; const void *q; /* Constraint error (C90 6.3.16.1): */ p = q; /* * This is correctly handled by TenDRA (4.2*). It is an error, and * TenDRA tells you the C90 section. * * This is incorrectly handled by gcc. It is only a warning (even * with -pedantic). gcc doesn't tell you the standard section. * * This is incorrectly handled by clang. It is only a warning (even * with -pedantic). clang doesn't tell you the standard section. * It prints more verbose and less useful message telling you that * this is controlled by * -Wincompatible-pointer-types-discards-qualifiers. Turning this * off gives a non-C compiler that doesn't even warn for the error. */ /* Cast to prevent the error: */ p = (void *)q; /* * This quietens TenDRA, gcc and clang. * * This can be be too quiet, so gcc has a -Wcast-qual feature to * turn the warning back on. FreeBSD uses this excessively, and * this has resulted in some correct const poisoning and some * abominations like __DECONST() and its use. * * But -Wcast-qual is just broken in clang. It has no effect for * the above, even with -pedantic. I don't know of any * -Wno-broken-cast-qual flag to fix this. */ /* The error can also be prevented by casting through an integer: */ p = (void *)(void *)(uintptr_t)(const volatile void *)q; /* * First we cast to (const volatile void *) to get a pointer on which * uintptr_t is useful (in case q is not already a qualified void *). * Then we cast to uintptr_t. This exploits the bug that -Wcast-qual * is broken for conversions to integers even for gcc. There should * be a way to avoid -Wcast-qual, but not this normal cast. The * __DE*() abominations use this. Then we cast to (void *) to get * the same result as casting the original pointer to (void *) without * the -Wcast-qual warning. The __DE*() abominations are ugly, but * not ugly enough to do this correctly. They assume that all pointers * have the same representation. Finally, we cast to the lvalue's * type, in case this is not (void *). __DE*() has a parameter for * this. Actually, this step is not needed, except in C++ or when * the final type is an integer (this integer type must be either * intptr_t or uintptr_t to work and to avoid warnings from gcc). */ Bruce