From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20764 invoked by alias); 24 Feb 2003 23:08:25 -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 20757 invoked from network); 24 Feb 2003 23:08:24 -0000 Received: from unknown (HELO brown.csi.cam.ac.uk) (131.111.8.14) by 172.16.49.205 with SMTP; 24 Feb 2003 23:08:24 -0000 Received: from student.cusu.cam.ac.uk ([131.111.179.82] helo=kern.srcf.societies.cam.ac.uk ident=mail) by brown.csi.cam.ac.uk with esmtp (Exim 4.10) id 18nRhv-0001wn-00; Mon, 24 Feb 2003 23:08:23 +0000 Received: from jsm28 (helo=localhost) by kern.srcf.societies.cam.ac.uk with local-esmtp (Exim 3.35 #1 (Debian)) id 18nRhv-0001Hd-00; Mon, 24 Feb 2003 23:08:23 +0000 Date: Mon, 24 Feb 2003 23:13:00 -0000 From: "Joseph S. Myers" X-X-Sender: To: cc: Michael Matz , Subject: Re: ISO Aliasing rules question In-Reply-To: <200302242126.h1OLQeo7017579@localhost.redhat.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2003-02/txt/msg01657.txt.bz2 On Mon, 24 Feb 2003 law@redhat.com wrote: > >The basic "what is an object?" question is discussed in Nick Maclaren's > >discussion with a title something like that, posted to the WG14 reflector > >some time ago, required reading for anyone contemplating such issues; ask > >him for a copy if you don't have one. > Do you have a contact address for Nick? I wandered > > http://std.dkuug.dk/jtc1/sc22/wg14 > > But couldn't find a reference to that paper. nmm1@cus.cam.ac.uk. I don't think it made a formal WG14 paper, just a mail to the reflector. > >In this case, a (in main) has declared type (so effective type) struct s1, > >so _if_ the structure is the relevant object then access through the type > >struct s2 would be undefined. But if you declared a as double, and then > >cast &a to each pointer type, then I think all accesses in f would be > >legitimate: an object of effective type double is accessed through > >structure types with an element of that type. > But in "f" we have the following > > a->d = 1.0 > return b->d + 1.0; > > According to an earlier message, that is just "shorthand" for: > > (*a).d = 1.0 > return (*b).d + 1.0 > > Which seems to me to clearly access "a" and "b" first, then their > appropriate field, which it would seem to me to run afoul of the > aliasing rules. If the effective type is double, then the accesses to a and b are OK, since those structs contain a double. And if the effective type is double because the declared type is double (in the variant example I gave), accesses and modifications cannot change the effective type to something else. -- Joseph S. Myers jsm28@cam.ac.uk