home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / std / cplus / 1103 < prev    next >
Encoding:
Text File  |  1992-08-22  |  1.8 KB  |  46 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!uunet.ca!frumious!pat
  3. From: pat@frumious.uucp (Patrick Smith)
  4. Subject: Re: this == 0 for nonvirtual functions
  5. Message-ID: <1992Aug22.031740.678@frumious.uucp>
  6. Date: Sat, 22 Aug 1992 03:17:40 GMT
  7. Reply-To: uunet.ca!frumious!pat
  8. References: <1992Aug18.045605.14220@sunb10.cs.uiuc.edu> <1992Aug20.215455.17279@microsoft.com> <1992Aug21.044448.8282@sunb10.cs.uiuc.edu>
  9. Organization: None
  10. Lines: 34
  11.  
  12. pjl@sparc10.cs.uiuc.edu (Paul Lucas) writes:
  13. |In <1992Aug20.215455.17279@microsoft.com> jimad@microsoft.com (Jim Adcock) writes:
  14. |
  15. |>In article <1992Aug18.045605.14220@sunb10.cs.uiuc.edu> pjl@sparc10.cs.uiuc.edu (Paul Lucas) writes:
  16. |>|    To reiterate, all I would like is to guarantee that the *call*
  17. |>|    to a non-virtual member-function will succeed and that it's my
  18. |>|    responsibility to check for a non-nil 'this'.
  19. |
  20. |>First, note that this would not come at "zero" cost.  As in the case of
  21. |>assigning to a reference, requiring "this" to be non-null allows compilers
  22. |>to avoid generating code to preserve nullness when adjusting pointers
  23. |>in the case of MI.  In the case of references, this issue has already
  24. |>been reviewed and decided upon: one is not allowed to have null references.
  25. |
  26. |    I was under the impression that for MI, once a this pointer became
  27. |    zero it has to stay zero, so it constitutes a special-case now.
  28. |    Hence, why wouldn't be a zero-cost feature?
  29.  
  30.  
  31. class Derived : public Base1, public Base2 {};
  32. Derived* p;
  33. Base2* q = p;
  34.     // Here the compiler must guarantee that if p was 0,
  35.     // then q will be 0.  This might require extra code
  36.     // to be generated and executed.
  37.  
  38. p->Base2::f();
  39.     // Here the compiler is allowed to _assume_ that p is not 0,
  40.     // so the extra code to handle the case p == 0 is not needed.
  41.  
  42. -- 
  43. Patrick Smith
  44. uunet.ca!frumious!pat
  45. pat%frumious.uucp@uunet.ca
  46.