Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent behavior in safe checking of conversion to void #3373

Open
dlangBugzillaToGithub opened this issue Nov 18, 2024 · 1 comment
Open

Comments

@dlangBugzillaToGithub
Copy link
Owner

Walter Bright reported this on 2024-11-18T18:36:48Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=24866

CC List

  • Richard (Rikki) Andrew Cattermole

Description

```
@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.
@dlangBugzillaToGithub
Copy link
Owner Author

alphaglosined commented on 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant