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