🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3323

Re: Is this allowed in C?

#3323
From: T. William Wells
Date: Thu, 28 Jan 1993 15:28
21 lines
1388 bytes
In article <1993Jan26.4502.4824@dosgate> "peter curran" <peter.curran@canrem.com> writes:
:           void *p;
:    p = malloc(1);
:
: Are there any alignment restrictions on the allocated memory?

Yes. The reason is that even though you may not store a double
there, the rules on casting require that you be able to assign
the pointer to a pointer to double and back again without
changing the pointer. E.g., on a machine that has a double
pointer that can't also represent arbitrary char pointers, the
returned value would have to be such that it is representable as
a double pointer. However, the compiler may cheat. On most
machines, you can't really tell whether the pointer is properly
aligned or not except by storing into it and you could never
actually store a double there so if the compiler does cheat, no
strictly conforming program could tell the difference.

---
Bill                            { rutgers | decwrl | telesci }!twwells!bill
bill@twwells.com
Technical Details
Message-ID: <C1KLn8.MAu@twwells.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!agate!ames!sun-barr!cs.utexas.edu!rutgers!twwells!bill
References: <1993Jan26.4502.4824@dosgate>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!agate!ames!sun-barr!cs.utexas.edu!rutgers!twwells!bill
From: bill@twwells.com (T. William Wells)
Newsgroups: comp.std.c
Subject: Re: Is this allowed in C?
Message-ID: <C1KLn8.MAu@twwells.com>
Date: 28 Jan 93 15:28:17 GMT
References: <1993Jan26.4502.4824@dosgate>
Distribution: comp
Organization: None, Mt. Laurel, NJ
Lines: 21