home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!microsoft!wingnut!pauljo
- From: pauljo@microsoft.com (Paul Johns)
- Subject: Re: Bug in BC/C++ 2.0 ?
- Message-ID: <1992Dec23.202206.29576@microsoft.com>
- Date: 23 Dec 92 20:22:06 GMT
- Organization: Microsoft: Redmond, Washington, USA
- Keywords: bugs
- References: <rogerl.724699309@Minsk>
- Lines: 35
-
- What's happening here is that the rules in C++ changed
- AFTER the Borland 2.0 compiler was written.
-
- In the old (before AT&T 2.1, I believe) days, you had
- to specify the size of the array you were deleting.
- And you had to get it right. The old Borland compiler
- is compatible with this old rule.
-
- So "delete [] ..." is not legal for your compiler.
- You have to supply a the size of the array between
- the []'s.
-
- An alternative that was used in the past was to omit
- the []'s entirely if the array was an array of a built-in
- type.
-
- I **DO NOT** recommend this. If you do this, the compiler
- will generate a delete for a single object, not an array
- of objects. Using the wrong semantics for delete gives
- undefined behavior.
-
- What I do recommend is that you either:
-
- 1. Upgrade your compiler to one that's AT&T 2.1-compliant.
- I think you should consider Microsoft C++, but I
- work for Microsoft and own Microsoft stock, so I
- have a clear bias. :)
-
- 2. Put the size in the delete. This is upwards-compatible:
- it's ignored in AT&T 2.1 and 3.0. This can be a little
- bit of a pain, but it's probably cheaper than upgrading.
-
- Good luck!
-
- // Paul Johns
-