home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!spool.mu.edu!sol.ctr.columbia.edu!usc!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmb
- From: tmb@arolla.idiap.ch (Thomas M. Breuel)
- Newsgroups: comp.lang.c++
- Subject: Re: zero-length datatype
- Message-ID: <TMB.92Sep14145655@arolla.idiap.ch>
- Date: 14 Sep 92 18:56:55 GMT
- References: <23654@alice.att.com> <1992Sep11.185505.17536@cadsun.corp.mot.com>
- <23659@alice.att.com> <TMB.92Sep12212903@arolla.idiap.ch>
- <23661@alice.att.com>
- Sender: news@ai.mit.edu
- Reply-To: tmb@idiap.ch
- Distribution: comp
- Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
- Perceptive)
- Lines: 39
- In-reply-to: ark@alice.att.com's message of 13 Sep 92 15:19:04 GMT
-
- In article <23661@alice.att.com> ark@alice.att.com (Andrew Koenig) writes:
-
- >In article <TMB.92Sep12212903@arolla.idiap.ch> tmb@idiap.ch writes:
-
- >> Well, it might be good to remain compatible, in the sense that every
- >> object that has non-zero size in ISO C also have a non-zero size in
- >> C++. However, since there are no objects of type "void" (or of some
- >> other, newly introduced, distinguished type with zero size) in ISO C,
- >> there can't be any harm in letting objects of this new type have zero
- >> size: the behavior of existing code would not be affected.
- >
- >That is not quite true, especially in the presence of templates.
- >
- >I expect that there will be some committee members who will say
- >that they want to be able to assume that objects of any type at all
- >are nonzero in size and admitting a new empty type would violate
- >that assumption. And indeed it might even affect old C code, if that
- >code uses a type that is macro-expanded into something not known until
- >the code is actually compiled.
-
- I discussed this issue at great depth in a previous posting.
-
- To summarize again:
-
- Yes, it is obviously true that if you hand a "void" as an argument to
- a template function (or template macro) that was written with the
- assumption that there are no zero-length datatypes, that template
- function may not behave as expected. But that's true for any other new
- type or type-related construct that C++ adds: handing a new quad
- precision datatype to a numerical template function, for example,
- might cause non-termination.
-
- Existing code can't legally hand "void" to an existing template
- function, hence it will not be affected by the feature. If you write
- new code that uses an old template function, then you better make sure
- that the types you use work for that template function; that's true
- for _any_ kind of type you might use, not just "void".
-
- Thomas.
-