Consider the following code: class T {} shared(T) allocClassMem() { void *p; // assume p is allocated here return cast(shared(T))p; } This yields: Error: direct access to shared `cast(shared(T))p` is not allowed, see `core.atomic` How is one supposed to allocate shared memory if casting is not allowed?
This is blocking the templatization of the _d_new_class druntime hook.
Update, the problem is not the casting. Casting is fine. The problem is the fact that the result of the cast is a shared expression that is returned, therefore it needs to be synchronized.
@RazvanN7 created dlang/dmd pull request #14836 "Fix Issue 23639 - Casting to shared not allowed with -preview=nosharedaccess" fixing this issue: - Fix Issue 23639 - Casting to shared not allowed with -preview=nosharedaccess https://github.com/dlang/dmd/pull/14836
dlang/dmd pull request #14836 "Fix Issue 23639 - Casting to shared not allowed with -preview=nosharedaccess" was merged into master: - a799c1b59ea617c0237f30ada65438a8a6d05657 by RazvanN7: Fix Issue 23639 - Casting to shared not allowed with -preview=nosharedaccess https://github.com/dlang/dmd/pull/14836