home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / std / c / 3333 < prev    next >
Encoding:
Text File  |  1993-01-07  |  1.7 KB  |  40 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!stanford.edu!nntp.Stanford.EDU!dkeisen
  3. From: dkeisen@leland.Stanford.EDU (Dave Eisen)
  4. Subject: Re: Struct hack one last time (one last time)
  5. Message-ID: <1993Jan7.200813.10289@leland.Stanford.EDU>
  6. Sender: news@leland.Stanford.EDU (Mr News)
  7. Organization: Sequoia Peripherals, Inc.
  8. Date: Thu, 7 Jan 93 20:08:13 GMT
  9. Lines: 29
  10.  
  11. In article <1993Jan7.145117.8220@jarvis.csri.toronto.edu> flaps@dgp.toronto.edu (Alan J Rosenthal) writes:
  12. >steve@taumet.com (Steve Clamage) writes:
  13. >>An implementation is allowed to add padding to the end of a struct.
  14. >>Suppose that the implementation adds space to the end of each struct
  15. >>type where it encodes information used for run-time error checking.
  16. >
  17. >Can't do that... what happens when you malloc one of them?
  18. >
  19. >    struct whatever *p = (struct whatever *)malloc(sizeof(struct whatever));
  20. >
  21. >Immediately after the malloc, if p is not null you can start using the struct,
  22. >but it won't have that run-time-error-checking information, so it will fault.
  23.  
  24. I don't know whether or not implementations are allowed to
  25. do what Steve is suggesting here, but I don't think this
  26. is a reason why it couldn't. Couldn't the compiler, as part
  27. of the code it emits to convert the (void *) returned by
  28. malloc also emit instructions to set up the information that
  29. Steve is postulating here? Or is there language in the the
  30. standard that forbids a conversion from one pointer type to
  31. another to affect the block of memory to which this pointer 
  32. points?
  33.  
  34.  
  35. -- 
  36. Dave Eisen                               Sequoia Peripherals: (415) 967-5644
  37. dkeisen@leland.Stanford.EDU              Home:                (415) 321-5154
  38.        There's something in my library to offend everybody. 
  39.           --- Washington Coalition Against Censorship
  40.