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

[core.atomic] atomicStore not work with struct that has template parameter list and function pointer (-preview=all) #17502

Open
thewilsonator opened this issue Dec 12, 2024 · 0 comments
Labels
Druntime Specific to druntime Severity:normal

Comments

@thewilsonator
Copy link
Contributor

Transfered from https://issues.dlang.org/show_bug.cgi?id=24736 from dlang/phobos#9876

Description

import core.atomic; // Compile with -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.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Druntime Specific to druntime Severity:normal
Projects
None yet
Development

No branches or pull requests

1 participant