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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!microsoft!hexnut!jimad
  3. From: jimad@microsoft.com (Jim Adcock)
  4. Subject: Re: Is this a compiler bug?
  5. Message-ID: <1992Dec14.212823.20514@microsoft.com>
  6. Date: 14 Dec 92 21:28:23 GMT
  7. Organization: Microsoft Corporation
  8. References: <1992Dec8.183122.1@vax1.bham.ac.uk> <KANZE.92Dec11165414@slsvdnt.us-es.sel.de> <1992Dec11.193023.27787@news2.cis.umn.edu>
  9. Lines: 26
  10.  
  11. In article <1992Dec11.193023.27787@news2.cis.umn.edu> hansen@deci.cs.umn.edu (David Hansen) writes:
  12. |In article <KANZE.92Dec11165414@slsvdnt.us-es.sel.de>, kanze@us-es.sel.de (James Kanze) writes:
  13. |[..]
  14. ||> 
  15. ||> If your compiler accepts this code, then it is broken.  (I am
  16. ||> supposing that NULL is defined as either 0 or 0L; however, in this
  17. ||> case, nothing changes if it is defined as (void*)0.)  "fptr" and the
  18. ||> results of "(fptr = bar())" are both pointers to member functions, and
  19. ||> *not* pointers.  There is no implicit (nor explicit) cast from a
  20. ||> pointer to member function to an int, a long, or a pointer, so it is
  21. ||> not legal to compare a pointer to member function to NULL.
  22. ||> There is *no* special value for pointers to members, the equivalent to
  23. ||> NULL for pointers.  So if there are cases where "bar()" cannot return
  24. ||> a legal value, some other arrangements must be made for it to return a
  25. ||> status.
  26. |
  27. |There is no equivalent to void* for pointers to members -- see p. 70.
  28. |Is this, perhaps, where the confusion might lie?
  29.  
  30. I think the confusion lies in assuming that ((void*)0) could be an
  31. acceptable implementation of NULL in C++.  ((void*)0) is acceptable
  32. in C.  It is not acceptable in C++.  The rules of pointer type compatibility
  33. have changed, and are more restrictive in C++.  Thus ((void*)0) no longer
  34. flies.  This is a source of frequent trouble for C++ programmers trying to
  35. use old C .h files.
  36.  
  37.