home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11705 < prev    next >
Encoding:
Internet Message Format  |  1992-07-28  |  2.2 KB

  1. Path: sparky!uunet!pipex!demon!cix.compulink.co.uk!vadim
  2. Newsgroups: comp.lang.c++
  3. From: vadim@cix.compulink.co.uk (Vadim Lebedev)
  4. Subject: Re: Renew?
  5. Cc: vadim@cix.compulink.co.uk
  6. Reply-To: vadim@cix.compulink.co.uk
  7. Date: Wed, 29 Jul 1992 00:04:00 +0000
  8. Message-ID: <memo.547224@cix.compulink.co.uk>
  9. Sender: usenet@gate.demon.co.uk
  10. Lines: 44
  11.  
  12. In-Reply-To: <23322@alice.att.com> ark@alice.att.com (Andrew Koenig)
  13.  
  14. In artcile <23322@alice.att.com> ark@alice.att.com (Andrew Koenig)
  15. writes:
  16.  
  17.  
  18. > >   ObjWithRenew *p; 
  19. > >   p = (ObjWithRenew *)realloc(old, newsize);
  20. > >   p->renewed(s);  // We can do this because realloc copied
  21. > >            // the vptr too
  22. > No such luck.  People are entitled to write classes whose objects,
  23. > for example, store their addresses in other data structures.  In general,
  24. > you cannot expect to be able to copy the bits that represent an
  25. > arbitrary object from here to there without breaking things.
  26.  
  27. I  agree, that a pointer to original object stored somewhere
  28. else creates a dangerous situation, but this is still true even if the
  29. 'operator renew' was built-in in the language. Renew and realloc should
  30. be always used with caution.  
  31.  
  32. > Moreover, implementations that use pointers rather than offsets to
  33. > locate virtual base classes are guaranteed to break under such movement.
  34. > That includes all cfront-based implementations.
  35.  
  36. I agree with this too. Well, storage allocation and deallocation are
  37. always VERY implementation dependent and tend to be rather non-portable
  38. across different implementations, and this particular implementation
  39. will not work with Cfront.  It works, however, with Zortech compiler.
  40. Actually the point i was trying to made is that the 'operator renew' 
  41. functionallity could be implemented using existing language facilities.
  42. Of course if the thing could be provided automatically by the language
  43. it would be more robust.
  44.  
  45. BTW, maybe there is a way to patch virtual base pointers in Cfront 
  46. implementation.
  47.  
  48. -----------------------------------------------------------------------
  49. Vadim Lebedev                      |   Kortex International
  50. vadim@cix.compulink.co.uk          |   139-147 av. Paul-Vaillant Couturier
  51.                                    |   93126 La Courneuve - CEDEX, France
  52.  
  53.  
  54.