🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Pointer Comparisons

#1160
From: Jim Adcock
Date: Thu, 24 Dec 1992 20:37
38 lines
1591 bytes
In article <1992Dec23.172735.15352@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
|ARM requires non-zero length objects doesnt it?

No, ARM does not make such a requirement.  ARM requires sizeof(Ob) to
be greater than zero.  And ARM requires new Ob to return a distinct address.
But this is not the same as requiring Ob to have non-zero length.
The basic underlying requirement is that the space that Ob takes as an
element of an array be greater than zero, so that pointers to different
elements in the array have different values.  This can be achieved for
zero-length objects by requiring them to have at least one-byte trailing
alignment padding when placed in arrays.  When used as a member of a structure,
the object wouldn't necessarily have the same padding and alignment
requirements.  For example ARM *explicitly* makes no requirement of
implementations in the following example:

class A {};

class B
{
public:
	A a1;
public:
	A a2;
};

main()
{
	B b;
	A* p1 = &(b.a1);
	A* p2 = &(b.a2);

	if (p1 == p2)
		cout << "its undefined according to ARM!\n";
	else
		cout << "boring case -- but still undefined behavior!\n";

	return 0;
}
Technical Details
Message-ID: <1992Dec24.203726.26481@microsoft.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!microsoft!hexnut!jimad
References: <1992Dec20.000341.6417@ucc.su.OZ.AU> <5451@holden.lulea.trab.se> <1992Dec23.172735.15352@ucc.su.OZ.AU>

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.203726.26481@microsoft.com>
Date: 24 Dec 92 20:37:26 GMT
Organization: Microsoft Corporation
References: <1992Dec20.000341.6417@ucc.su.OZ.AU> <5451@holden.lulea.trab.se> <1992Dec23.172735.15352@ucc.su.OZ.AU>
Lines: 38