Article View: comp.bugs.4bsd
Article #85Ultrix CC bug?
From: Bj|rn Larsson
Date: Fri, 15 Sep 1989 15:03
Date: Fri, 15 Sep 1989 15:03
50 lines
1721 bytes
1721 bytes
Hello netters,
yesterday I came upon a strange behaviour in Ultrix 'C'. The following
test program causes cc to complain about the left-hand side of the marked
expression.
main()
{
short *p;
tst(p);
}
tst (p)
short *p;
{
long l;
l = *((long *) p)++; /* <<< Here! */
}
In my view,
p is a pointer to short,
(long *) p is a pointer to long,
((long *) p) is also a pointer to long,
((long *) p)++ increments the above *long* pointer,
*((long *) p) is the long pointed to,
thus
*((long *) p)++ has the value of the *long* pointed
to by p, and the *long* pointer is
set to point to the next long (i.e.
if sizeof (long)== 2*sizeof(short)
then p will be incremented by two,
counted in short's).
Any objections? I could add that both Turbo C, MicroSoft C, and the
MicroTek C 68000 cross-compiler compile this as I believe 'correctly'.
And this is no problem, I fixed it at another place - but it's inte-
resting to hear what yous C compilers do...
Bjorn
--
====================== InfoVox = Speech Technology =======================
Bjorn Larsson, INFOVOX AB : ...seismo!mcvax!kth!sunic!infovax!bl
Box 2503 : bl@infovox.se
S-171 02 Solna, Sweden : Phone (+46) 8 735 80 90
Technical Details
Message-ID:
<199@infovax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mcsun!sunic!infovax!blShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mcsun!sunic!infovax!bl From: bl@infovax.UUCP (Bj|rn Larsson) Newsgroups: comp.bugs.4bsd,eunet.bugs.4bsd Subject: Ultrix CC bug? Keywords: Ultrix, BSD4.x, CC, Bug? Message-ID: <199@infovax.UUCP> Date: 15 Sep 89 15:03:08 GMT Organization: INFOVOX AB, SOLNA, SWEDEN Lines: 50