Article View: comp.std.c++
Article #1154Re: Pointer comparisons
From: Jim Adcock
Date: Thu, 24 Dec 1992 01:12
Date: Thu, 24 Dec 1992 01:12
32 lines
2125 bytes
2125 bytes
In article <1992Dec18.181029.1061@taumet.com> steve@taumet.com (Steve Clamage) writes: |Right. In the C Standard, it is stated explicitly that two pointers |of the same type which compare equal point to the same object or |function. There is no such statment for C++ in the ARM or in the |current C++ Committee working draft. What needs to be made clear includes what is meant by "point to the same object." As in my example the pointers *do* point to the same object, and they do compare equal. It's just that one pointer refers to an enclosing object, and one pointer the enclosed object. Same object, just not identically the same object. Also needs to be clarified all the different implications. If two pointers which compare equal point to the same object, do two pointers to 'the same object' compare equal? Do two pointers not comparing equal not point to the same object? Do two pointers not to the same object not compare equal? These issues are much more obvious in C than in C++. Ultimately, I do not believe worrying about these pointer "details" is very important unless one first decides what properties of object identity C++ objects must have and why. The current permission of C++ compilers to create temporaries at will kind of blows object identity out of the water. Why worry about pointer equality, then? One thing you might want to consider is dividing C++ objects into two categories -- those with and without virtual functions or virtual bases. Then just require "C" rules on those without virtualness. But require some reasonable "object oriented" rules of object identity for those with virtualness. Alternately, just leave it implementation defined ;-)
Technical Details
Message-ID:
<1992Dec24.011254.1982@microsoft.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!microsoft!hexnut!jimadReferences:
<BzDs2x.wA@frumious.uucp> <1992Dec17.151642.9954@bcrka451.bnr.ca> <1992Dec18.181029.1061@taumet.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!sparky!uunet!microsoft!hexnut!jimad From: jimad@microsoft.com (Jim Adcock) Subject: Re: Pointer comparisons Message-ID: <1992Dec24.011254.1982@microsoft.com> Date: 24 Dec 92 01:12:54 GMT Organization: Microsoft Corporation References: <BzDs2x.wA@frumious.uucp> <1992Dec17.151642.9954@bcrka451.bnr.ca> <1992Dec18.181029.1061@taumet.com> Lines: 32