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

Compiler hangs when declaring compile-time constant function pointer argument of recursive function #4852

Open
bplu4t2f opened this issue Feb 16, 2025 · 0 comments

Comments

@bplu4t2f
Copy link

Context

My intention here is to have a function pointer argument that's marked as compile time constant so that it can be inlined.

In the case that this is not supported, it's still a bug since the compiler shouldn't choke on it.

recursive_func :: proc(i : int, $test : proc(int) -> bool) {
	if (test(i)) {
		recursive_func(i + 1, test)
	}
}

testfunc :: proc(i : int) -> bool {
	return i < 10
}
  • Operating System & Odin Version:
    Odin: dev-2025-02-nightly:584fdc0
    OS: Windows 11 Home Basic (version: 23H2), build 22631.4751
    CPU: AMD Ryzen Z1 Extreme
    RAM: 9937 MiB
    Backend: LLVM 18.1.8

Expected Behavior

Inlining of test(i) when recursive_func is called with a concrete argument.

Current Behavior

Compiler hangs forever. First it allocates a lot of memory for a while, and then it ramps up CPU usage.

Failure Information (for bugs)

Not appliable

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

package main

main :: proc() {
	recursive_func(0, testfunc)
}

recursive_func :: proc(i : int, $test : proc(int) -> bool) {
	if (test(i)) {
		recursive_func(i + 1, test)
	}
}

testfunc :: proc(i : int) -> bool {
	return i < 10
}
odin build . -debug -show-timings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant