https://issues.dlang.org/show_bug.cgi?id=24793

Nick Treleaven <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #6 from Nick Treleaven <[email protected]> ---
comment 4:
> we're risking memory safety issues with stuff like this with the introduction 
> of language features such as placement new.

Surely passing a `void*` to placement new is not going to be @safe anyway.

comment 5:
> Unless that function checks the validity of `p` at runtime, that's not a safe 
> interface

True. But there is value in @system code of const(void*) not converting to
void* - that is useful with some C APIs. GLib uses const void* parameters
(aliased as gconstpointer) here:
https://docs.gtk.org/glib/callback.CompareFunc.html.

So perhaps explicit casting of a const T* to a void* should be @safe, because
safe D can't mutate the pointee byte(s). But I don't think it should be
implicitly allowed.

--

Reply via email to