Bug 24866 – Inconsistent behavior in safe checking of conversion to void

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-11-18T18:36:48Z
Last change time
2024-12-13T19:38:34Z
Keywords
safe
Assigned to
No Owner
Creator
Walter Bright
Moved to GitHub: dmd#20548 →

Comments

Comment #0 by bugzilla — 2024-11-18T18:36:48Z
``` @safe: struct T { int* a,b,c; } void bar(void[24]); void gee(void*); void test() { static T t; gee(&t); // no error bar(cast(void[24])t); // cast from `T` to `void[24]` not allowed in safe code } ``` Both should be allowed or both should error.
Comment #1 by alphaglosined — 2024-11-18T19:00:06Z
Due to placement new, I'm on the side of disallowing conversion to ``void*`` and ``void[]`` in ``@safe``. We have been relying on a language feature like that not existing and it opens up a major can of worms to have it. Related: https://issues.dlang.org/show_bug.cgi?id=24772
Comment #2 by robert.schadek — 2024-12-13T19:38:34Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20548 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB