Thread overview
[Issue 2270] cast produces invalid arrays at runtime
Sep 09, 2019
RazvanN
Sep 10, 2019
anonymous4
Dec 17, 2022
Iain Buclaw
September 09, 2019
https://issues.dlang.org/show_bug.cgi?id=2270

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

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

--- Comment #14 from RazvanN <razvan.nitu1305@gmail.com> ---
I cannot reproduce this issue. It seems that the cast works properly now. closing as WORKSFORME.

--
September 09, 2019
https://issues.dlang.org/show_bug.cgi?id=2270

Steven Schveighoffer <schveiguy@yahoo.com> changed:

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

--- Comment #15 from Steven Schveighoffer <schveiguy@yahoo.com> ---
No, it still doesn't work right. The example wasn't complete. Essentially, the cast shouldn't compile.

https://run.dlang.io/is/8Hihr0

Note that I would expect the call to foo to produce output, but it doesn't.

If I add in a printout of the class and interface addresses, you get identical addresses. That is, the cast didn't perform the thunk to get to the actual interface record. Which would be expected (a correct cast would have to reallocate the array).

I think the correct thing to do here is require a reinterpret cast if you really want this cast to succeed (cast to void * and back).

--
September 09, 2019
https://issues.dlang.org/show_bug.cgi?id=2270

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|D1 (retired)                |D2
           Severity|enhancement                 |normal

--- Comment #16 from Steven Schveighoffer <schveiguy@yahoo.com> ---
Huh, this really was a D1 issue. But it persists in D2, so updating the data.

--
September 10, 2019
https://issues.dlang.org/show_bug.cgi?id=2270

anonymous4 <dfj1esp02@sneakemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

--- Comment #17 from anonymous4 <dfj1esp02@sneakemail.com> ---
I'd say it's by design. Maybe a warning will be fine.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=2270

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P4

--