On Tuesday, 1 March 2022 at 16:40:50 UTC, Paul Backus wrote:
It's a bug in druntime. `destroy` needs to reinterpret the
class reference as a `void*` to pass it to `rt_finalize`:
https://github.com/dlang/druntime/blob/v2.098.1/src/object.d#L4209
However, `cast(void*)` is not the correct way t
On Tuesday, 1 March 2022 at 04:59:49 UTC, Mike Parker wrote:
On Tuesday, 1 March 2022 at 04:29:56 UTC, cc wrote:
```d
struct A {}
class B {
A opCast(T : A)() {
return A();
}
}
void main() {
auto b = new B();
destroy(b);
}
```
fails with
```
dmd2\wi
On Tuesday, 1 March 2022 at 08:16:13 UTC, Mike Parker wrote:
On Tuesday, 1 March 2022 at 07:16:11 UTC, bauss wrote:
Right now if you want to add an additional cast then you have
to implement ALL the default behaviors and then add your
custom cast.
It's two template functions like the OP used
On Tuesday, 1 March 2022 at 08:16:13 UTC, Mike Parker wrote:
On Tuesday, 1 March 2022 at 07:16:11 UTC, bauss wrote:
Right now if you want to add an additional cast then you have
to implement ALL the default behaviors and then add your
custom cast.
It's two template functions like the OP used
On Tuesday, 1 March 2022 at 07:16:11 UTC, bauss wrote:
Right now if you want to add an additional cast then you have
to implement ALL the default behaviors and then add your custom
cast.
It's two template functions like the OP used: one for T to catch
everything, and one specialization.
On Tuesday, 1 March 2022 at 04:59:49 UTC, Mike Parker wrote:
It makes sense to me, and I would say the bug is that it's not
documented.
Personally it doesn't make sense to me. I don't think it should
override default behaviors, but just add onto it, so you can add
an additional cast.
Ri
On Tuesday, 1 March 2022 at 04:59:49 UTC, Mike Parker wrote:
You could also specialize on `void*`, as that's the type that
was failing to compile
I meant "instead", not also.
On Tuesday, 1 March 2022 at 04:29:56 UTC, cc wrote:
```d
struct A {}
class B {
A opCast(T : A)() {
return A();
}
}
void main() {
auto b = new B();
destroy(b);
}
```
fails with
```
dmd2\windows\bin\..\..\src\druntime\import\object.d(4209):
Error: te
```d
struct A {}
class B {
A opCast(T : A)() {
return A();
}
}
void main() {
auto b = new B();
destroy(b);
}
```
fails with
```
dmd2\windows\bin\..\..\src\druntime\import\object.d(4209): Error:
template instance `opCast!(void*)` does not match templ