🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #797

alias accessing

#797
From: Norman Diamond
Date: Fri, 20 Oct 1989 08:03
24 lines
1347 bytes
Consider the following program fragment:

  int *a;
  const int *b;
  int z;

  b = a = (int *) malloc (sizeof (int));

  z = *b;  /* legal access to *a (aliased) according to section 3.3 */
  z = *a;  /* illegal access to *b (aliased) according to section 3.3 */

Do I really understand section 3.3 correctly?  If b is actually
declared in some other function which never wants to change the
value of *b, I still cannot put a "const" on it, unless I'm sure
that it will be aliased only to other consts.

[I have read the offending section three times slowly before posting
this foot.]

-- 
Norman Diamond, Sony Corp. (diamond%ws.sony.junet@uunet.uu.net seems to work)
  Should the preceding opinions be caught or     |  James Bond asked his
  killed, the sender will disavow all knowledge  |  ATT rep for a source
  of their activities or whereabouts.            |  licence to "kill".
Technical Details
Message-ID: <10981@riks.csl.sony.co.jp>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!ginosko!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!ginosko!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond
From: diamond@csl.sony.co.jp (Norman Diamond)
Newsgroups: comp.std.c
Subject: alias accessing
Message-ID: <10981@riks.csl.sony.co.jp>
Date: 20 Oct 89 08:03:08 GMT
Reply-To: diamond@ws.sony.junet (Norman Diamond)
Organization: Sony Computer Science Laboratory Inc., Tokyo, Japan
Lines: 24