home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!think.com!yale.edu!ira.uka.de!slsvaat!josef!kanze
- From: kanze@us-es.sel.de (James Kanze)
- Subject: Re: Is this a compiler bug?
- In-Reply-To: hansen@deci.cs.umn.edu's message of Fri, 11 Dec 1992 19:30:23 GMT
- Message-ID: <KANZE.92Dec14211143@slsvdnt.us-es.sel.de>
- Sender: news@us-es.sel.de
- Organization: SEL
- References: <AC.92Dec6175233@ludwig.it.apollo.hp.com> <1992Dec8.183122.1@vax1.bham.ac.uk>
- <KANZE.92Dec11165414@slsvdnt.us-es.sel.de>
- <1992Dec11.193023.27787@news2.cis.umn.edu>
- Date: 14 Dec 92 21:11:43
- Lines: 61
-
- 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.
-
- |> Ummm, I don't think so. The ARM on p. 158 describes a possible implementation
- |> of pointers to member functions, and it explicitly describes a decision
- |> "To allow the representation of a null pointer to member to be 0..."
-
- |> Furthermore, on p. 161, the initialization of a pointer to member function
- |> to zero is given, thus:
-
- |> int (D::*pmf0)() = 0;
-
- |> which kind of implies the conversion of 0 to a pointer to member function
- |> does, indeed, exist.
-
- |> |> 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.
-
- This will teach me to post before checking. My copy of the ARM was at
- home, and I was at the office.
-
- Although the parts you quote are from the comments, and as such, not
- strictly part of the standard, in section 4.8, it explicitly says that
- "A constant expression that evaluates to zero is converted to a
- pointer to member. It is guaranteed that this value will produce a
- pointer to member distinguishable from any other pointer to member."
- Which is exactly the phrasing used when defining a NULL pointer.
-
- So you do have NULL pointers to members.
-
- |> There is no equivalent to void* for pointers to members -- see p. 70.
- |> Is this, perhaps, where the confusion might lie?
-
- Well, part of my confusion may be due to the fact that I constantly
- stress that pointers to members are *not* pointers, that I
- automatically expect them to have *none* of the characteristics of
- pointers.
-
- However, I'm almost sure that I read this somewhere. I was so sure,
- in fact, that when I checked your quote, I immediately supposed that
- there was a contradiction in the ARM. Which lead me to the other
- quote, confirming what you say.
- --
- --
- James Kanze email: kanze@us-es.sel.de
- GABI Software, Sarl., 8 rue du Faisan, F-67000 Strasbourg, France
- Conseils en informatique industrielle --
- -- Beratung in industrieller Datenverarbeitung
-