From owner-freebsd-current Thu Jul 5 23:38:10 2001 Delivered-To: freebsd-current@freebsd.org Received: from netau1.alcanet.com.au (ntp.alcanet.com.au [203.62.196.27]) by hub.freebsd.org (Postfix) with ESMTP id D39F837B405 for ; Thu, 5 Jul 2001 23:38:04 -0700 (PDT) (envelope-from jeremyp@gsmx07.alcatel.com.au) Received: from mfg1.cim.alcatel.com.au (mfg1.cim.alcatel.com.au [139.188.23.1]) by netau1.alcanet.com.au (8.9.3 (PHNE_22672)/8.9.3) with ESMTP id QAA28779; Fri, 6 Jul 2001 16:37:53 +1000 (EST) Received: from gsmx07.alcatel.com.au by cim.alcatel.com.au (PMDF V5.2-32 #37641) with ESMTP id <01K5M8L8H4HCVFBE3Q@cim.alcatel.com.au>; Fri, 6 Jul 2001 16:37:21 +1000 Received: (from jeremyp@localhost) by gsmx07.alcatel.com.au (8.11.1/8.11.1) id f666bh072894; Fri, 06 Jul 2001 16:37:43 +1000 (EST envelope-from jeremyp) Content-return: prohibited Date: Fri, 06 Jul 2001 16:37:43 +1000 From: Peter Jeremy Subject: Re: chgrp broken on alpha systems In-reply-to: ; from mjacob@feral.com on Thu, Jul 05, 2001 at 10:22:11PM -0700 To: Matthew Jacob Cc: freebsd-current@FreeBSD.ORG Mail-Followup-To: Matthew Jacob , freebsd-current@FreeBSD.ORG Message-id: <20010706163743.D506@gsmx07.alcatel.com.au> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-disposition: inline User-Agent: Mutt/1.2.5i References: <20010706150804.B506@gsmx07.alcatel.com.au> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 2001-Jul-05 22:22:11 -0700, Matthew Jacob wrote: >> IMHO, the problem splits into two categories: >> Firstly, sizeof(long) (and sizeof(void *)) differ between the Alpha >> and the i386. > >Yes. This tends to be caught by the alpha compiler but the i386. >It'd be nice if there were a -Wpun. For example: > >x.c: > >int >func(char *p) >{ > int j = (int) p; > return j + 1; >} > >On i386, 'gcc -fsyntax-only -Wall x.c' produces no error. On >NetBSD/alpha (same compiler, really), this produces: > >x.c: In function `func': >x.c:4: warning: cast from pointer to integer of different size > >It'd be *really* nice if we could add a flag where such errors could be >checked for and emitted for an i386 build. David would know for certain, but I think this is messy to detect. As I see it, the problem is that when casting a pointer type to an integer type, gcc only looks at the lengths of the types - on an i386, sizeof(int) == sizeof(long) == sizeof(void *), whereas on an Alpha, sizeof(int) != sizeof(long) == sizeof(void *). Whilst it is possible to change the check so that it verifies that the integer type is `long' (or longer), this may cause other problems. A further obstacle is that [u]intptr_t maps to an [u]int on the i386 and I don't think that gcc can tell the difference between (int) and (intptr_t) when applied to a pointer. One solution would be to make [u]intptr_t a `magic' type in gcc and have it whinge whenever a pointer or [u]intptr_t was cast or assigned to anything other than a pointer or [u]intptr_t. This is probably a non-trivial task in gcc and would lead to lots of false positives. Overall, I think that making developers more aware of cross-platform issues, combined with the availability of test boxes (like beast) is a better solution. It's definitely unreasonable to expect all developers to own machines for all the target architectures. Another random thought: If it was easier to build/install a cross-platform version of gcc, it might be easier to convince developers to at least check that compiling on different platforms works before committing. Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message