Subject: Re: [ub] C provenance semantics proposal
From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2019-04-13 03:21:18
On 13/04/2019 08.42, Uecker, Martin wrote:
> Am Freitag, den 12.04.2019, 21:48 +0200 schrieb Jens Maurer:
>> On 11/04/2019 23.36, Uecker, Martin wrote:
>>> Am Donnerstag, den 11.04.2019, 15:07 -0600 schrieb Martin Sebor:
>>>> Â You have several compiler writers/standards
>>>> people explaining it's by design in the bug reports you found.
>>> No.Â On the clang buf report there was no disagreement
>>> and the bug was fixed in commit r220343.
>> I can't comment on Clang's policy for addressing perceived bugs in
>> their code, but C++17 clearly says in [expr.eq] p2.1 for the
>> definition of ==:
>> "â If one pointer represents the address of a complete object, and another pointer
>> represents the address one past the last element of a different complete object,
>> the result of the comparison is unspecified."
>> This was added to address Core Issue 1652 "Object addresses in constexpr
>> expressions", and Richard Smith, the person fixing the Clang "bug", was
>> intimately involved in this change.
>> So, I'd say the current status in C++ is deliberate and at least
>> cognizant of the then-recent Clang bug report. Furthermore, C DR 260
>> "Implementations [...] may also treat pointers based on different origin
>> as distinct even though they are bitwise identical."
>> which seems to be consistent with the C++ "unspecified value"
> I know, but I was talking about ISO C which says:
> "Two pointers compare equal if and only if both are null pointers, both
> are pointers to the same object (including a pointer to an object and
> a subobject at its beginning) or function, both are pointers to one
> past the last element of the same array object, or one is a pointer
> to one past the end of one array object and the other is a pointer
> to the start of a different array object that happens to immediately
> follow the first array object in the address space."
So, it seems the opinion of WG14 in C DR 260 is at odds with the current
normative text. Maybe WG14 wants to revisit and update C DR 260, at
least with a marker "obsolete" or so. Or is there a follow-up DR that
I haven't found yet?
SG12 list run by herb.sutter at gmail.com