home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: Having this=0, class-name: :main() and tasking in c++
- Message-ID: <1992Jul28.161438.2862@taumet.com>
- Organization: TauMetric Corporation
- References: <1DDA4ACFA5BF800C41@ursula.lucas.lu.se> <23318@alice.att.com> <1992Jul27.155949.6165@sunb10.cs.uiuc.edu>
- Distribution: usa
- Date: Tue, 28 Jul 1992 16:14:38 GMT
- Lines: 51
-
- pjl@sparc13.cs.uiuc.edu (Paul Lucas) writes:
-
- >In <23318@alice.att.com> ark@alice.att.com (Andrew Koenig) writes:
-
- >>In article <1DDA4ACFA5BF800C41@ursula.lucas.lu.se> KOSU_MATSB@ROUTH.KOSUFY.LU.SE writes:
-
- >>> Question #1: Having a 0 "this" pointer. Standard?
-
- >>No. ARM page 176:
-
- >> The effect of calling a nonstatic member function of a class X
- >> for something that is not an object of class X is undefined.
-
- >*****> Oops! I was in error about my previous post; sorry. But _why_
- > isn't guaranteed to work for nonstatic, nonvirtual member
- > functions?
-
- > C++ C-code
- > === ======
- > ((X*)0)->f(); ==> f( /* this= */ 0 );
-
- Let's call a non-static non-virtual member function an "ordinary member
- function".
-
- An ordinary member function must be called in conjunction with some
- object of appropriate type. Conceptually, it gets a "this" pointer
- to that object. The language specification does not say how this is
- to be implemented. You show the obvious implementation, but the
- obvious implementation is not required.
-
- No object will be located at the address represented by literal zero.
- Any member function which attempts to manipulate non-static class data,
- or which calls functions which do, will fail with a null "this" pointer.
-
- An ordinary member function usually operates on class data, or calls
- other class functions which do. It might seem reasonable to say that
- an ordinary member function which uses no non-static class data, calls
- not functions which do, and calls no virtual functions of the class,
- should be guaranteed to work with a null "this" pointer. (Such a
- function would be expected to be static, but let's ignore that.)
-
- It might be that the implementation requires more than a simple
- passing of the "this" pointer, and the manipulation might fail on a
- null pointer.
-
- For all these reasons, the language standard cannot guarantee success
- for any member function which gets a null "this" pointer.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
- Vice Chair, ANSI C++ Committee, X3J16
-