🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #142

Re: this == 0 for nonvirtual functions

#142
From: Patrick Smith
Date: Sat, 22 Aug 1992 03:17
34 lines
1884 bytes
pjl@sparc10.cs.uiuc.edu (Paul Lucas) writes:
|In <1992Aug20.215455.17279@microsoft.com> jimad@microsoft.com (Jim Adcock) writes:
|
|>In article <1992Aug18.045605.14220@sunb10.cs.uiuc.edu> pjl@sparc10.cs.uiuc.edu (Paul Lucas) writes:
|>|	To reiterate, all I would like is to guarantee that the *call*
|>|	to a non-virtual member-function will succeed and that it's my
|>|	responsibility to check for a non-nil 'this'.
|
|>First, note that this would not come at "zero" cost.  As in the case of
|>assigning to a reference, requiring "this" to be non-null allows compilers
|>to avoid generating code to preserve nullness when adjusting pointers
|>in the case of MI.  In the case of references, this issue has already
|>been reviewed and decided upon: one is not allowed to have null references.
|
|	I was under the impression that for MI, once a this pointer became
|	zero it has to stay zero, so it constitutes a special-case now.
|	Hence, why wouldn't be a zero-cost feature?


class Derived : public Base1, public Base2 {};
Derived* p;
Base2* q = p;
	// Here the compiler must guarantee that if p was 0,
	// then q will be 0.  This might require extra code
	// to be generated and executed.

p->Base2::f();
	// Here the compiler is allowed to _assume_ that p is not 0,
	// so the extra code to handle the case p == 0 is not needed.

-- 
Patrick Smith
uunet.ca!frumious!pat
pat%frumious.uucp@uunet.ca
Technical Details
Message-ID: <1992Aug22.031740.678@frumious.uucp>
Path: arc1-ca.pugleaf.net!sparky!uunet!uunet.ca!frumious!pat
References: <1992Aug18.045605.14220@sunb10.cs.uiuc.edu> <1992Aug20.215455.17279@microsoft.com> <1992Aug21.044448.8282@sunb10.cs.uiuc.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++
Path: arc1-ca.pugleaf.net!sparky!uunet!uunet.ca!frumious!pat
From: pat@frumious.uucp (Patrick Smith)
Subject: Re: this == 0 for nonvirtual functions
Message-ID: <1992Aug22.031740.678@frumious.uucp>
Date: Sat, 22 Aug 1992 03:17:40 GMT
Reply-To: uunet.ca!frumious!pat
References: <1992Aug18.045605.14220@sunb10.cs.uiuc.edu> <1992Aug20.215455.17279@microsoft.com> <1992Aug21.044448.8282@sunb10.cs.uiuc.edu>
Organization: None
Lines: 34