home *** CD-ROM | disk | FTP | other *** search
- Path: 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
-
- 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
-