Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
August 01, 2018 pointer cast from const(Y) to immutable(void*)** is not supported at compile time | ||||
---|---|---|---|---|
| ||||
Why does the following work in DMD 2.080 and LDC 1.10, but not in DMD 2.081 and LDC 1.11 beta: https://run.dlang.io/is/dSVruv And is there a way to enforce the cast like a static_cast in C++? |
August 01, 2018 Re: pointer cast from const(Y) to immutable(void*)** is not supported at compile time | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hakan Aras | On Wednesday, 1 August 2018 at 16:25:28 UTC, Hakan Aras wrote:
>
> https://run.dlang.io/is/dSVruv
>
Whoops, that was the wrong one. It's fixed now.
|
August 02, 2018 Re: pointer cast from const(Y) to immutable(void*)** is not supported at compile time | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hakan Aras | On Wednesday, 1 August 2018 at 20:10:44 UTC, Hakan Aras wrote: > On Wednesday, 1 August 2018 at 16:25:28 UTC, Hakan Aras wrote: > >> >> https://run.dlang.io/is/dSVruv >> > > Whoops, that was the wrong one. It's fixed now. https://issues.dlang.org/show_bug.cgi?id=19134 As a workaround remove static, as that causes y to be initialised at compile time. static here has nothing to do with static_cast in C++. The analogy to a static_cast would be const X x = new Y(); casting up the hierarchy, as opposed to dynamic casting down the hierarchy. |
August 02, 2018 Re: pointer cast from const(Y) to immutable(void*)** is not supported at compile time | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicholas Wilson | On Thursday, 2 August 2018 at 01:39:58 UTC, Nicholas Wilson wrote: > https://issues.dlang.org/show_bug.cgi?id=19134 > I wasn't quite sure whether it's a bug since it happens in both compilers. Thanks for opening the issue. > As a workaround remove static, as that causes y to be initialised at compile time. I do want it at compiletime though. > static here has nothing to do with static_cast in C++. > The analogy to a static_cast would be > > const X x = new Y(); > > casting up the hierarchy, as opposed to dynamic casting down the hierarchy. Sorry, I actually meant a reinterpret_cast. I always get those mixed up. But now that I look at it again I don't see how that would help me, since my code isn't the one trying to to casting. |
August 02, 2018 Re: pointer cast from const(Y) to immutable(void*)** is not supported at compile time | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hakan Aras | On Thursday, 2 August 2018 at 02:13:41 UTC, Hakan Aras wrote: > On Thursday, 2 August 2018 at 01:39:58 UTC, Nicholas Wilson wrote: > >> https://issues.dlang.org/show_bug.cgi?id=19134 >> > > I wasn't quite sure whether it's a bug since it happens in both compilers. Thanks for opening the issue. > For future reference the only time you should consider LDC/GDC distinct from DMD is codegen, i.e. compiler causes your code to crash. This is a frontend bug so it affects all the major compilers. >> As a workaround remove static, as that causes y to be initialised at compile time. > > I do want it at compiletime though. > >> static here has nothing to do with static_cast in C++. >> The analogy to a static_cast would be >> >> const X x = new Y(); >> >> casting up the hierarchy, as opposed to dynamic casting down the hierarchy. > > Sorry, I actually meant a reinterpret_cast. I always get those mixed up. But now that I look at it again I don't see how that would help me, since my code isn't the one trying to to casting. Ah, unfortunately you're stuck then. |
August 02, 2018 Re: pointer cast from const(Y) to immutable(void*)** is not supported at compile time | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hakan Aras | On Thursday, 2 August 2018 at 02:13:41 UTC, Hakan Aras wrote: > I do want it at compiletime though. Totally understandable; that's a regression and needs to be fixed. See https://github.com/dlang/dmd/pull/8362#pullrequestreview-142565787. |
Copyright © 1999-2021 by the D Language Foundation