[LLVMdev] LLVM 2.4 problem? (resend)
Mike Stump
mrs at apple.com
Wed Oct 15 15:29:37 PDT 2008
On Oct 15, 2008, at 1:09 PM, David Vandevoorde wrote:
> On Oct 15, 2008, at 3:53 PM, Mike Stump wrote:
> [...]
>> Objects are defined like so:
>>
>> Two pointers of
>> the same type compare equal if and only if they are both null,
>> both
>> point to the same object or function, or both point one past the
>> end
>> of the same array.
>>
>> This means they _must_ compare !=, if they are different objects.
>
>
> Aha! Thanks for quoting that: It's from an expired standard (1998,
> presumably). The 2003 standard has changed the words for that, taking
> away the property under discussion (for a different reason -- see Core
> Issue 73).
A distinction without a difference. They are trying to word smith
this to get it right, however, the underlying semantics are trivial
and not in dispute. The part you seem to be missing is kinda
fundamental, unless there is linkage, there is no linkage. What
linkage means is exactly the notion of if two entities refer to the
same object or not, or to put it another way, if two entities have the
same address. Pointing off the end of an array doesn't necessarily
yield a pointer to an object. It represents a value that can be
manipulated to refer to an object, say, with p-1.
I can quote n2461 if you prefer:
Two pointers of the same type compare equal if and only if they are both
null, both point to the same function, or both represent the same
address (3.9.2).
A valid value of an object pointer type represents either the address
of a byte in memory (1.7) or a null pointer (4.10). If an object of
type T is located at an address A, a pointer of type cv T* whose value
is the address A is said to point to that object, regardless of how
the value was obtained.
Static and automatic storage durations are associated with objects
introduced by declarations (3.1) and implicitly cre-
ated by the implementation (12.2).
A declaration (clause 7) introduces names into a translation unit or
redeclares names introduced by previous declarations.
An object is a region of storage.
An object is created by a definition (_basic.def_)
Each declaration _creates_ an object. The word create means that each
has a region of bytes, distinct from all others.
> The changes to address Core issue 73 invalidates your reasoning
No, they don't. I'm describing a fundamental feature of C and C++
that cannot be disputed. The most that can be done is to add a rule
that says objects declared with a const type can be merged, meaning
that objects with the same value may (implementation defined or
unspecified) refer to the address of one of them. A rule like this
could be added to C or C++, but has not been to the best of my
knowledge.
More information about the llvm-dev
mailing list