🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1254

struct hack, was Re: strcpy implementation question

#1254
From: David Adrien Tanguay
Date: Fri, 04 Sep 1992 01:53
20 lines
1532 bytes
diamond@jit081.enet.dec.com (03-Sep-1992 1325) writes:
>In article <PINKAS.92Sep2173635@skywalker.intel.com> pinkas@skywalker.intel.com (Israel Pinkas) writes:
>>The variable length struct is a hack.  There is nothing in the language
>>that prevents the compiler from performing bounds checking on accesses to
>>name.
>
>Uh, nothing except the standard's definitions of [], unary *, and binary +
>operators.  :-R rhetoric.
>Bounds checking is not allowed to affect output of a valid but ugly program.

Could you flesh this argument out? I had the impression that the last time
it came up here the conclusion was that this trick was not sanctioned
(i.e., a bounds checker could fail). After all, 3.3.6 "Additive Operators"
says that you aren't guaranteed to go past the end of an array object,
so if you start with the trailing array (in the struct) you can't go past
its end. (You could if you used a different "handle" for the malloc return
value.)
-- 
David Tanguay       dat@Thinkage.on.ca  dat@Thinkage.com  uunet!thinkage!dat
Thinkage, Ltd.           Kitchener, Ontario, Canada          [43.40N 80.47W]
Technical Details
Message-ID: <1992Sep4.015335.3612@thinkage.on.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watmath!thinkage!dat
References: <9209030426.AA24169@enet-gw.pa.dec.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watmath!thinkage!dat
From: dat@thinkage.on.ca (David Adrien Tanguay)
Subject: struct hack, was Re: strcpy implementation question
Message-ID: <1992Sep4.015335.3612@thinkage.on.ca>
Organization: Thinkage, Ltd.
References: <9209030426.AA24169@enet-gw.pa.dec.com>
Date: Fri, 4 Sep 1992 01:53:35 GMT
Lines: 20