Article View: net.bugs.v7
Article #12Re: sizeof type botch (utzoo.1248)
From: utah-cslepreau
Date: Wed, 06 Jan 1982 12:17
Date: Wed, 06 Jan 1982 12:17
21 lines
1090 bytes
1090 bytes
We decided that this is a compiler bug and fixed it. What prompted this
rash action is that the "bug" has disastrous consequences for a
canonical Unix code sequence:
/* Read a "record" (struct), then back up to the beginning of it */
/* in order to update it in place. */
read(fd, (char *) &record, sizeof record);
lseek(fd, (long) -(sizeof record), 1);
Because the sizeof expr was unsigned, you seek to a very large positive number!
(Of course one can write: -((long) sizeof record) but it's easy to forget...)
The obvious negative aspect of this change is that sizeof (objects > 32K)
doesn't work, but we think that's the lesser evil. One can always do
(sizeof(array[0]) * ARRAYLEN).
-------------
The fix follows, to c01.c.
43c43
< t1->type = UNSIGN;
---
> t1->type = INT; /* was UNSIGN; J.Lepreau 5/81 */
-------------
Technical Details
Message-ID:
<anews.Autah-cs.156>Path:
arc1-ca.pugleaf.net!utzoo!decvax!duke!chico!harpo!utah-cs!lepreauShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!decvax!duke!chico!harpo!utah-cs!lepreau From: utah-cs!lepreau Newsgroups: net.bugs.v7 Subject: Re: sizeof type botch (utzoo.1248) Date: Wed, 06 Jan 1982 12:17:38 +0000 Message-ID: <anews.Autah-cs.156>