dmd icon indicating copy to clipboard operation
dmd copied to clipboard

segfault with template functions in a returned struct type, when calling from inside a with statement.

Open winrg opened this issue 1 month ago • 0 comments

I've tried to pare this down as much as I can. With dmd 2.111.0, the following causes a segfault:

void
usecrasher()
{
	with(crasher) method!0(0);

	// doesn't crash:
	// crasher.method!0(0);
	// with(crasher) method!0;
}

auto
crasher()
{
	struct Foo {
		// commenting either stops the crash
		void method(int x)(int a) { }
		void method(int x)() { }

		// also segfaults:
		// void method(int x)(int a) if(x == 0) { }
		// void method(int x)(int a) if(x != 0) { }

		// doesn't segfault:
		// void method(int x)() if(x == 0) { }
		// void method(int x)() if(x != 0) { }
	}
	
	Foo foo;
	return foo;
}

winrg avatar Oct 31 '25 16:10 winrg