Thread overview
[Issue 23972] class identity check is broken
Jun 05, 2023
Bolpat
Oct 16, 2023
Dlang Bot
Oct 17, 2023
RazvanN
Oct 17, 2023
RazvanN
Oct 19, 2023
Dennis
Oct 20, 2023
Bolpat
Nov 14, 2023
Dlang Bot
Nov 14, 2023
Dlang Bot
Dec 16, 2023
Basile-z
June 05, 2023
https://issues.dlang.org/show_bug.cgi?id=23972

Bolpat <qs.il.paperinik@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |qs.il.paperinik@gmail.com

--
October 16, 2023
https://issues.dlang.org/show_bug.cgi?id=23972

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #1 from Dlang Bot <dlang-bot@dlang.rocks> ---
@SixthDot created dlang/dmd pull request #15696 "fix issue 23972 - class identity check is broken" fixing this issue:

- fix issue 23972 - class identity check is broken

  insert casts to Object when interfaces are used as IdentityExp operands

https://github.com/dlang/dmd/pull/15696

--
October 17, 2023
https://issues.dlang.org/show_bug.cgi?id=23972

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |razvan.nitu1305@gmail.com
         Resolution|---                         |INVALID

--- Comment #2 from RazvanN <razvan.nitu1305@gmail.com> ---
Thank you for taking the time of writing this bug report, however, as explained in this comment [1], the bug report is invalid. I1 and I2 are different types, therefore the is expression is correct in returning false. The fact that the pointer points to the same memory address is not relevant in this case since the compiler does not do any dataflow analysis to see where the interface was assigned.

[1] https://github.com/dlang/dmd/pull/15696#pullrequestreview-1682054176

--
October 17, 2023
https://issues.dlang.org/show_bug.cgi?id=23972

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #3 from RazvanN <razvan.nitu1305@gmail.com> ---
Actually I was thinking of is expressions, not the is operator. The bug is valid.

--
October 19, 2023
https://issues.dlang.org/show_bug.cgi?id=23972

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dkorpel@live.nl

--- Comment #4 from Dennis <dkorpel@live.nl> ---
I think the spec is wrong (or too vague) here. The interface object has a slightly different address than the class object, so the pointers aren't equal. `is` should be a simple bit compare, and not be doing casting logic for classes.

--
October 20, 2023
https://issues.dlang.org/show_bug.cgi?id=23972

--- Comment #5 from Bolpat <qs.il.paperinik@gmail.com> ---
(In reply to Dennis from comment #4)
> I think the spec is wrong (or too vague) here. The interface object has a
> slightly different address than the class object, so the pointers aren't
> equal.
> `is` should be a simple bit compare, and not be doing casting logic for
> classes.

No, in this case, it shouldn't. If one actually wants to compare the pointer values, one can always cast to `void*` and compare the pointers. The fact that the class handles are represented by pointers is really an implementation detail. The current behavior is both surprising and useless. If the `is` operator does not provide class object identity, it should not be there at all; the error message in that case could point out that an explicit cast to Object is needed, but if that's what programmers will do anyways, why not provide something like an operator for it that does The Right Thing™?

--
November 14, 2023
https://issues.dlang.org/show_bug.cgi?id=23972

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
@dkorpel created dlang/dlang.org pull request #3726 "Fix 23972 - class identity check is broken" fixing this issue:

- Fix 23972 - class identity check is broken

https://github.com/dlang/dlang.org/pull/3726

--
November 14, 2023
https://issues.dlang.org/show_bug.cgi?id=23972

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dlang.org pull request #3726 "Fix 23972 - class identity check is broken" was merged into master:

- 99530f59602022930f6c2e634f3809a03fd0c8b6 by Dennis Korpel:
  Fix 23972 - class identity check is broken

https://github.com/dlang/dlang.org/pull/3726

--
December 16, 2023
https://issues.dlang.org/show_bug.cgi?id=23972

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dhasenan@gmail.com

--- Comment #8 from Basile-z <b2.temp@gmx.com> ---
*** Issue 19633 has been marked as a duplicate of this issue. ***

--