Article View: comp.std.c
Article #4295Re: Variable length struct hack
From: Mark Brader
Date: Sun, 29 Oct 1995 08:58
Date: Sun, 29 Oct 1995 08:58
25 lines
1692 bytes
1692 bytes
>>>> If you malloc, say, 3 bytes, malloc is not required to provide alignment
>>>> for a 4-byte object, say an int.
>>> It is funny. Last time this question came up, someone posted that the
>>> committee believes that malloc result is always aligned for everything! Will
>>> that person please repost?
>> I asked this in a Defect Report. The response is still in balloting, but
>> will almost certainly be that it must be correctly aligned.
>
> It is unclear to me why a defect report is needed here. Will the ruling affect
> any strictly conforming (or even any "strongly conforming") program?
By simple logic, it could do so only if it (a) amends the standard or
(b) is incorrect.
The ruling will *determine whether* the technique mentioned a few articles
back in the thread, of implementing a variable length struct by malloc()ing
an object of size less than what sizeof returns for the struct, can occur
in a strictly conforming program.
--
Mark Brader, msb@sq.com, SoftQuad Inc., Toronto
MARTIANS BUILD TWO IMMENSE CANALS IN TWO YEARS.
Vast Engineering Works Accomplished in an Incredibly Short Time by Our
Planetary Neighbors. -- N.Y.Times headline, August 27, 1911
My text in this article is in the public domain.
Technical Details
Message-ID:
<1995Oct29.085800.18890@sq.com>Path:
arc1-ca.pugleaf.net!howland.reston.ans.net!torn!sq!msbReferences:
<463egk$jbb@nntp.Stanford.EDU> <465qd1$k90@newshost.lanl.gov> <DGxwnJ.2x7@stdc.demon.co.uk> <46o94c$5sa@rdsunx.crd.ge.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!howland.reston.ans.net!torn!sq!msb From: msb@sq.com (Mark Brader) Subject: Re: Variable length struct hack Message-ID: <1995Oct29.085800.18890@sq.com> Organization: SoftQuad Inc., Toronto, Canada References: <463egk$jbb@nntp.Stanford.EDU> <465qd1$k90@newshost.lanl.gov> <DGxwnJ.2x7@stdc.demon.co.uk> <46o94c$5sa@rdsunx.crd.ge.com> Date: Sun, 29 Oct 1995 08:58:00 GMT