Skip to content

Wrap multivar_func callback in adaptive_integration - #104

Open
mkruskal-google wants to merge 1 commit into
NanoComp:masterfrom
mkruskal-google:fix-integrator-callback-wrapper
Open

mkruskal-google wants to merge 1 commit into
NanoComp:masterfrom
mkruskal-google:fix-integrator-callback-wrapper

Conversation

@mkruskal-google

Copy link
Copy Markdown

In src/integrator.c, adaptive_integration previously cast its callback to the internal integrand pointer type despite mismatched parameter signedness and const qualification. This adds a stack-allocated wrapper struct and static trampoline mirroring src/cintegrator.c, leaving the public C API unchanged. Standalone C builds compile cleanly under strict function-pointer cast warnings, and standalone integrator and geometry test builds pass under Clang indirect-call sanitizers. The integrator harness also passes under undefined-behavior checks, and those geometry tests pass under GCC with OpenMP.

Note: Drafted and locally tested with AI coding assistance.

Calling `multivar_func` (`double (*)(int, double *, void *)`) through
a cast to `integrand` (`double (*)(unsigned, const double *, void *)`)
causes indirect-call signature mismatches (`-Wcast-function-type-strict`,
`-fsanitize=function`, `-fsanitize=kcfi`).

Use a stack-allocated `num_wrap_data` struct and `num_wrap` trampoline
matching `integrand` (analogous to `cnum_wrap` in `src/cintegrator.c`),
leaving the public `multivar_func` typedef and `adaptive_integration` API
unchanged.
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

Successfully merging this pull request may close these issues.

1 participant