home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / std / c / 3443 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  1.3 KB

  1. Path: sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!agate!ames!sun-barr!cs.utexas.edu!rutgers!twwells!bill
  2. From: bill@twwells.com (T. William Wells)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Is this allowed in C?
  5. Message-ID: <C1KLn8.MAu@twwells.com>
  6. Date: 28 Jan 93 15:28:17 GMT
  7. References: <1993Jan26.4502.4824@dosgate>
  8. Distribution: comp
  9. Organization: None, Mt. Laurel, NJ
  10. Lines: 21
  11.  
  12. In article <1993Jan26.4502.4824@dosgate> "peter curran" <peter.curran@canrem.com> writes:
  13. :           void *p;
  14. :    p = malloc(1);
  15. :
  16. : Are there any alignment restrictions on the allocated memory?
  17.  
  18. Yes. The reason is that even though you may not store a double
  19. there, the rules on casting require that you be able to assign
  20. the pointer to a pointer to double and back again without
  21. changing the pointer. E.g., on a machine that has a double
  22. pointer that can't also represent arbitrary char pointers, the
  23. returned value would have to be such that it is representable as
  24. a double pointer. However, the compiler may cheat. On most
  25. machines, you can't really tell whether the pointer is properly
  26. aligned or not except by storing into it and you could never
  27. actually store a double there so if the compiler does cheat, no
  28. strictly conforming program could tell the difference.
  29.  
  30. ---
  31. Bill                            { rutgers | decwrl | telesci }!twwells!bill
  32. bill@twwells.com
  33.