home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 17934 < prev    next >
Encoding:
Text File  |  1992-12-14  |  3.3 KB  |  76 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!think.com!yale.edu!ira.uka.de!slsvaat!josef!kanze
  3. From: kanze@us-es.sel.de (James Kanze)
  4. Subject: Re: Is this a compiler bug?
  5. In-Reply-To: hansen@deci.cs.umn.edu's message of Fri, 11 Dec 1992 19:30:23 GMT
  6. Message-ID: <KANZE.92Dec14211143@slsvdnt.us-es.sel.de>
  7. Sender: news@us-es.sel.de
  8. Organization: SEL
  9. References: <AC.92Dec6175233@ludwig.it.apollo.hp.com> <1992Dec8.183122.1@vax1.bham.ac.uk>
  10.     <KANZE.92Dec11165414@slsvdnt.us-es.sel.de>
  11.     <1992Dec11.193023.27787@news2.cis.umn.edu>
  12. Date: 14 Dec 92 21:11:43
  13. Lines: 61
  14.  
  15. In article <1992Dec11.193023.27787@news2.cis.umn.edu>
  16. hansen@deci.cs.umn.edu (David Hansen) writes:
  17.  
  18. |> In article <KANZE.92Dec11165414@slsvdnt.us-es.sel.de>, kanze@us-es.sel.de (James Kanze) writes:
  19. |> [..]
  20. |> |> 
  21. |> |> If your compiler accepts this code, then it is broken.  (I am
  22. |> |> supposing that NULL is defined as either 0 or 0L; however, in this
  23. |> |> case, nothing changes if it is defined as (void*)0.)  "fptr" and the
  24. |> |> results of "(fptr = bar())" are both pointers to member functions, and
  25. |> |> *not* pointers.  There is no implicit (nor explicit) cast from a
  26. |> |> pointer to member function to an int, a long, or a pointer, so it is
  27. |> |> not legal to compare a pointer to member function to NULL.
  28.  
  29. |> Ummm, I don't think so.  The ARM on p. 158 describes a possible implementation
  30. |> of pointers to member functions, and it explicitly describes a decision
  31. |> "To allow the representation of a null pointer to member to be 0..."
  32.  
  33. |> Furthermore, on p. 161, the initialization of a pointer to member function
  34. |> to zero is given, thus:
  35.  
  36. |>    int (D::*pmf0)() = 0;
  37.  
  38. |> which kind of implies the conversion of 0 to a pointer to member function
  39. |> does, indeed, exist.
  40.  
  41. |> |> There is *no* special value for pointers to members, the equivalent to
  42. |> |> NULL for pointers.  So if there are cases where "bar()" cannot return
  43. |> |> a legal value, some other arrangements must be made for it to return a
  44. |> |> status.
  45.  
  46. This will teach me to post before checking.  My copy of the ARM was at
  47. home, and I was at the office.
  48.  
  49. Although the parts you quote are from the comments, and as such, not
  50. strictly part of the standard, in section 4.8, it explicitly says that
  51. "A constant expression that evaluates to zero is converted to a
  52. pointer to member.  It is guaranteed that this value will produce a
  53. pointer to member distinguishable from any other pointer to member."
  54. Which is exactly the phrasing used when defining a NULL pointer.
  55.  
  56. So you do have NULL pointers to members.
  57.  
  58. |> There is no equivalent to void* for pointers to members -- see p. 70.
  59. |> Is this, perhaps, where the confusion might lie?
  60.  
  61. Well, part of my confusion may be due to the fact that I constantly
  62. stress that pointers to members are *not* pointers, that I
  63. automatically expect them to have *none* of the characteristics of
  64. pointers.
  65.  
  66. However, I'm almost sure that I read this somewhere.  I was so sure,
  67. in fact, that when I checked your quote, I immediately supposed that
  68. there was a contradiction in the ARM.  Which lead me to the other
  69. quote, confirming what you say.
  70. --
  71. --
  72. James Kanze                             email: kanze@us-es.sel.de
  73. GABI Software, Sarl., 8 rue du Faisan, F-67000 Strasbourg, France
  74. Conseils en informatique industrielle --
  75.                    -- Beratung in industrieller Datenverarbeitung
  76.