home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!demon!cix.compulink.co.uk!vadim
- Newsgroups: comp.lang.c++
- From: vadim@cix.compulink.co.uk (Vadim Lebedev)
- Subject: Re: Renew?
- Cc: vadim@cix.compulink.co.uk
- Reply-To: vadim@cix.compulink.co.uk
- Date: Wed, 29 Jul 1992 00:04:00 +0000
- Message-ID: <memo.547224@cix.compulink.co.uk>
- Sender: usenet@gate.demon.co.uk
- Lines: 44
-
- In-Reply-To: <23322@alice.att.com> ark@alice.att.com (Andrew Koenig)
-
- In artcile <23322@alice.att.com> ark@alice.att.com (Andrew Koenig)
- writes:
-
-
- > > ObjWithRenew *p;
- > > p = (ObjWithRenew *)realloc(old, newsize);
- > > p->renewed(s); // We can do this because realloc copied
- > > // the vptr too
- >
- > No such luck. People are entitled to write classes whose objects,
- > for example, store their addresses in other data structures. In general,
- > you cannot expect to be able to copy the bits that represent an
- > arbitrary object from here to there without breaking things.
-
- I agree, that a pointer to original object stored somewhere
- else creates a dangerous situation, but this is still true even if the
- 'operator renew' was built-in in the language. Renew and realloc should
- be always used with caution.
-
- >
- > Moreover, implementations that use pointers rather than offsets to
- > locate virtual base classes are guaranteed to break under such movement.
- > That includes all cfront-based implementations.
-
- I agree with this too. Well, storage allocation and deallocation are
- always VERY implementation dependent and tend to be rather non-portable
- across different implementations, and this particular implementation
- will not work with Cfront. It works, however, with Zortech compiler.
- Actually the point i was trying to made is that the 'operator renew'
- functionallity could be implemented using existing language facilities.
- Of course if the thing could be provided automatically by the language
- it would be more robust.
-
- BTW, maybe there is a way to patch virtual base pointers in Cfront
- implementation.
-
- -----------------------------------------------------------------------
- Vadim Lebedev | Kortex International
- vadim@cix.compulink.co.uk | 139-147 av. Paul-Vaillant Couturier
- | 93126 La Courneuve - CEDEX, France
-
-
-