home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / c / 13521 < prev    next >
Encoding:
Text File  |  1992-09-11  |  1.6 KB  |  57 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
  3. From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
  4. Subject: Re: typedef and memory allocation
  5. Message-ID: <9225523.27157@mulga.cs.mu.OZ.AU>
  6. Sender: news@cs.mu.OZ.AU
  7. Organization: Computer Science, University of Melbourne, Australia
  8. References: <3687@amethyst.math.arizona.edu>
  9. Distribution: usa
  10. Date: Fri, 11 Sep 1992 13:04:28 GMT
  11. Lines: 44
  12.  
  13. winfree@math.arizona.edu (Art Winfree) writes:
  14.  
  15. >typedef double vector[3]
  16.  
  17. There should be a semicolon at the end of the above typedef.
  18.  
  19. >main()
  20. >{
  21. >.
  22. >.
  23. >.
  24. >}
  25. >
  26. >funky_func()
  27. >{
  28. >vector bigarray[100];
  29. >.
  30. >.
  31. >.
  32. >}
  33. >
  34. >Question: Shouldn't a reasonable C compiler allocate enough
  35. >(3*100*sizeof(double)) memory for bigarray for use when funky_func()
  36. >is called? Evidently mine doesn't, since the code core dumps unless I
  37. >explicitly calloc in funky_func().
  38.  
  39. Either your compiler is broken, or there is a bug somewhere else in your code.
  40. (ie. in the elided part).
  41.  
  42. The only other possibility I can think of is that you might just possibly
  43. be getting a stack overflow, but that seems highly unlikely.
  44.  
  45. >I know typedef itself doesn't
  46. >cause any allocation, but are typedef'd types, as above, supposed to
  47. >be sizeof'd and variables invoking them given appropriate memory, even
  48. >if included in local function array definitions?
  49.  
  50. Yes, they are.
  51.  
  52. -- 
  53. Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
  54. This .signature virus is a self-referential statement that is true - but 
  55. you will only be able to consistently believe it if you copy it to your own
  56. .signature file!
  57.