Skip to content

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

Open
@bplu4t2f

Description

@bplu4t2f

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions