home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13567 < prev    next >
Encoding:
Internet Message Format  |  1992-09-12  |  1.7 KB

  1. Path: sparky!uunet!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmb
  2. From: tmb@arolla.idiap.ch (Thomas M. Breuel)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: zero-length datatype
  5. Message-ID: <TMB.92Sep12212903@arolla.idiap.ch>
  6. Date: 13 Sep 92 01:29:03 GMT
  7. References: <23654@alice.att.com> <1992Sep11.185505.17536@cadsun.corp.mot.com>
  8.     <23659@alice.att.com>
  9. Sender: news@ai.mit.edu
  10. Reply-To: tmb@idiap.ch
  11. Distribution: comp
  12. Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
  13.     Perceptive)
  14. Lines: 26
  15. In-reply-to: ark@alice.att.com's message of 12 Sep 92 15:54:04 GMT
  16.  
  17. In article <23659@alice.att.com> ark@alice.att.com (Andrew Koenig) writes:
  18.  
  19.    In article <1992Sep11.185505.17536@cadsun.corp.mot.com> shang@corp.mot.com writes:
  20.  
  21.    > That is why ISO C standard does not allow empty structure and zero 
  22.    > number of array.
  23.  
  24.    No, ISO C does allow empty structures.  It just says that they must
  25.    occupy a non-zero amount of memory.
  26.  
  27.    > But I don't see the reason why we can't have zero-size objects. Don't 
  28.    > say that the standard explicitly says that. I want to know why it says 
  29.    > that. So far, I haven't heard any convincing argument.
  30.  
  31.    I don't really know why.  What I do know is that the presence of
  32.    that requirement in the C standard makes it hard to avoid the same
  33.    requirement in the C++ standard.
  34.  
  35. Well, it might be good to remain compatible, in the sense that every
  36. object that has non-zero size in ISO C also have a non-zero size in
  37. C++. However, since there are no objects of type "void" (or of some
  38. other, newly introduced, distinguished type with zero size) in ISO C,
  39. there can't be any harm in letting objects of this new type have zero
  40. size: the behavior of existing code would not be affected.
  41.  
  42.                     Thomas.
  43.