From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16475 invoked by alias); 14 May 2003 22:04:51 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 16414 invoked from network); 14 May 2003 22:04:48 -0000 Received: from unknown (HELO crack.them.org) (146.82.138.56) by sources.redhat.com with SMTP; 14 May 2003 22:04:48 -0000 Received: from nevyn.them.org ([66.93.61.169] ident=mail) by crack.them.org with asmtp (Exim 3.12 #1 (Debian)) id 19G4Ml-0001EK-00; Wed, 14 May 2003 17:04:52 -0500 Received: from drow by nevyn.them.org with local (Exim 3.36 #1 (Debian)) id 19G4MH-0001TS-00; Wed, 14 May 2003 18:04:21 -0400 Date: Wed, 14 May 2003 22:04:00 -0000 From: Daniel Jacobowitz To: Gabriel Dos Reis Cc: Andreas Schwab , Brad Lucier , gcc@gcc.gnu.org Subject: Re: strict-aliasing and typedefs Message-ID: <20030514220420.GA29399@nevyn.them.org> Mail-Followup-To: Gabriel Dos Reis , Andreas Schwab , Brad Lucier , gcc@gcc.gnu.org References: <200305142056.h4EKujuX025820@banach.math.purdue.edu> <20030514214700.GA19731@nevyn.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.1i X-SW-Source: 2003-05/txt/msg01463.txt.bz2 On Wed, May 14, 2003 at 11:59:30PM +0200, Gabriel Dos Reis wrote: > Daniel Jacobowitz writes: > > | On Wed, May 14, 2003 at 11:31:49PM +0200, Gabriel Dos Reis wrote: > | > Andreas Schwab writes: > | > > | > [...] > | > > | > | int *sp; > | > | int *hp; > | > | > | > | |> I'm wondering if a Scheme->C compiler > | > | |> can use typedefs and ISO C's aliasing rules to tell gcc that certain > | > | |> memory locations cannot alias each other. > | > | > | > | One way to do this is to define differently named structures with a single > | > | member, but they may pessimize the generated code due to ABI > | > | peculiarities. > | > > | > As I understand it, he would like an object-based non-alias > | > optimization, I believe restrict is a good candidate. > | > | That depends. Brad's initial example could also be used for type-based > | non-alias optimization, for different sets of int objects - which is > | somewhat looser than restrict allows. > > I'm not sure I get what you meant. > > At the type-level, one cannot distingush an int* from another int*, > they are both int* so may alias each other. > > At the the object-level, where one considers different sets of objects > of the *same type*, one needs an additional information not provided > just by the type. What did I miss in your remark? You're entirely correct, but I think that what Brad wanted (based on his message) was: typedef int kindone; typedef int kindtwo; and then to have any kindtwo* pointer not alias any kindone* pointer. Which is not quite the same as restrict, and is not possible in C. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer