Article View: comp.std.c
Article #3338Re: Struct hack one last time (one last time)
From: Dave Eisen
Date: Thu, 07 Jan 1993 20:08
Date: Thu, 07 Jan 1993 20:08
29 lines
1823 bytes
1823 bytes
In article <1993Jan7.145117.8220@jarvis.csri.toronto.edu> flaps@dgp.toronto.edu (Alan J Rosenthal) writes:
>steve@taumet.com (Steve Clamage) writes:
>>An implementation is allowed to add padding to the end of a struct.
>>Suppose that the implementation adds space to the end of each struct
>>type where it encodes information used for run-time error checking.
>
>Can't do that... what happens when you malloc one of them?
>
> struct whatever *p = (struct whatever *)malloc(sizeof(struct whatever));
>
>Immediately after the malloc, if p is not null you can start using the struct,
>but it won't have that run-time-error-checking information, so it will fault.
I don't know whether or not implementations are allowed to
do what Steve is suggesting here, but I don't think this
is a reason why it couldn't. Couldn't the compiler, as part
of the code it emits to convert the (void *) returned by
malloc also emit instructions to set up the information that
Steve is postulating here? Or is there language in the the
standard that forbids a conversion from one pointer type to
another to affect the block of memory to which this pointer
points?
--
Dave Eisen Sequoia Peripherals: (415) 967-5644
dkeisen@leland.Stanford.EDU Home: (415) 321-5154
There's something in my library to offend everybody.
--- Washington Coalition Against Censorship
Technical Details
Message-ID:
<1993Jan7.200813.10289@leland.Stanford.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!nntp.Stanford.EDU!dkeisenShow Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!nntp.Stanford.EDU!dkeisen From: dkeisen@leland.Stanford.EDU (Dave Eisen) Subject: Re: Struct hack one last time (one last time) Message-ID: <1993Jan7.200813.10289@leland.Stanford.EDU> Sender: news@leland.Stanford.EDU (Mr News) Organization: Sequoia Peripherals, Inc. Date: Thu, 7 Jan 93 20:08:13 GMT Lines: 29