> Am 27.06.2024 um 20:55 schrieb Jason Merrill <ja...@redhat.com>:
> 
> On Thu, Jun 27, 2024 at 2:38 PM Richard Biener
> <richard.guent...@gmail.com> wrote:
>>>> Am 27.06.2024 um 19:04 schrieb Jason Merrill via Gcc <gcc@gcc.gnu.org>:
>>> 
>>> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2434r1.html
>>> proposes to require that repeated unspecified comparisons be
>>> self-consistent, which does not match current behavior in either GCC
>>> or Clang.  The argument is that the current allowance to be
>>> inconsistent is user-unfriendly and does not enable significant
>>> optimizations.  Any feedback about this?
>> 
>> Can you give an example of an unspecified comparison?  I think the only way 
>> to do what the paper wants is for the implementation to make the comparison 
>> specified (without the need to document it).  Is the self-consistency 
>> required only within some specified scope (a single expression?) or even 
>> across TUs (which might be compiled by different compilers or compiler 
>> versions)?
>> 
>> So my feedback would be to make the comparison well-defined.
>> 
>> I’m still curious about which ones are unspecified now.
> 
> https://eel.is/c++draft/expr#eq-3.1
> "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 is historically unspecified primarily because we don't want to
> force a particular layout of multiple variables.
> 
> See the example under "consequences for implementations" in the paper.

And how do we currently not have consistent behavior?  I don’t think we 
constantly fold such  comparisons in any way but we could take advantage of the 
unspecifiedness in more complex situations (though I can’t come up with one off 
my head).

Richard 

> Jason
> 

Reply via email to