Article View: comp.std.c
Article #4270Re: Variable length struct hack
From: Clive D.W. Feather
Date: Tue, 24 Oct 1995 06:28
Date: Tue, 24 Oct 1995 06:28
31 lines
1832 bytes
1832 bytes
In article <465qd1$k90@newshost.lanl.gov>, Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov> wrote: >> 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. > Do the record of responses contain only the `response' or also the logic by > which the resonse was reached?) The logic used is sometimes given in the responses, and sometimes not. Even when given, it isn't always easy to understand or agree with. In this case, it simply says that the Standard says "aligned for any type". > But can a struct not have stricter alignment than its first member? So, the > result of malloc certainly has to be aligned for an int, but is it aligned > for struct blah? Again, I am not asking about `practically', but what is > guaranteed. Yes and yes. -- Clive D.W. Feather | If you lie to the compiler, clive@demon.net (work, preferred) | it will get its revenge. clive@stdc.demon.co.uk (home) | - Henry Spencer
Technical Details
Message-ID:
<DGxwnJ.2x7@stdc.demon.co.uk>Path:
arc1-ca.pugleaf.net!stdc.demon.co.uk!cliveReferences:
<463egk$jbb@nntp.Stanford.EDU> <463lpa$qgo@newshost.lanl.gov> <46449u$nb2@rdsunx.crd.ge.com> <465qd1$k90@newshost.lanl.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!stdc.demon.co.uk!clive From: clive@stdc.demon.co.uk (Clive D.W. Feather) Newsgroups: comp.std.c Subject: Re: Variable length struct hack Date: Tue, 24 Oct 1995 06:28:30 GMT Organization: Demon Internet Limited (personal account) Message-ID: <DGxwnJ.2x7@stdc.demon.co.uk> References: <463egk$jbb@nntp.Stanford.EDU> <463lpa$qgo@newshost.lanl.gov> <46449u$nb2@rdsunx.crd.ge.com> <465qd1$k90@newshost.lanl.gov> Reply-To: clive@demon.net X-NNTP-Posting-Host: stdc.demon.co.uk