www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - pointer cast from const(Y) to immutable(void*)** is not supported at

reply Hakan Aras <hakan.aras live.at> writes:
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++?
Aug 01 2018
parent reply Hakan Aras <hakan.aras live.at> writes:
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.
Aug 01 2018
parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
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.
Aug 01 2018
parent reply Hakan Aras <hakan.aras live.at> writes:
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.
Aug 01 2018
next sibling parent Nicholas Wilson <iamthewilsonator hotmail.com> writes:
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.
Aug 01 2018
prev sibling parent kinke <kinke libero.it> writes:
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.
Aug 02 2018