[Issue 24736] New: core.atomic is not work with struct that has template parameter list and function pointer (-preview=all)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Sep 1 07:14:35 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24736
Issue ID: 24736
Summary: core.atomic is not work with struct that has template
parameter list and function pointer (-preview=all)
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: rayerd.wiz at gmail.com
import core.atomic; // Compile within -preview=all
enum VARS_AFTER_FP = true;
synchronized shared class A
{
static void proc() {}
void fn(ARGS...)(ARGS args)
{
static struct S
{
static if (VARS_AFTER_FP)
{
void function() fp;
ARGS vars;
}
else
{
ARGS vars;
void function() fp;
}
}
S s;
s.fp.atomicStore(&proc);
static foreach (i, e; args)
{
s.vars[i].atomicStore(e.atomicLoad());
}
}
}
void main()
{
auto a = new A;
a.fn(1); // OK
a.fn(2, "str"); // Runtime error when VARS_AFTER_FP is false.
a.fn("str", 3); // Runtime error when VARS_AFTER_FP is true.
}
--
More information about the Digitalmars-d-bugs
mailing list