# StaticCompiler: Debugging and calling basic math functions

**URL:** <https://discourse.julialang.org/t/staticcompiler-debugging-and-calling-basic-math-functions/93219>\
**Category:** General Usage\
**Tags:** question, compilation\
**Created:** [January 19, 2023, 3:54pm UTC](https://discourse.julialang.org/t/staticcompiler-debugging-and-calling-basic-math-functions/93219 "2023-01-19T15:54:52Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![wave\_and\_matter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wave_and_matter/32/202530_2.png) [@wave\_and\_matter](https://discourse.julialang.org/u/wave_and_matter)\
**Post date:** [January 20, 2023, 1:28pm UTC](https://discourse.julialang.org/t/staticcompiler-debugging-and-calling-basic-math-functions/93219/8 "2023-01-20T13:28:26Z")

</div>

Okay, so your solution did indeed work for the simple testcase :-). On top, i learned that i can use cis instead of exp and that this will supposedly be faster too (i only have exp(i\*real\_a) calls).

I also found another variety of the cis-function [in this forum post](https://discourse.julialang.org/t/poor-performance-of-the-cis-function/3402) which is less extra code and allegedly faster because it calls some optimized library.

```julia
const A = Ref{Cdouble}()
const B = Ref{Cdouble}()
function cis2_(x::Float64)
    ccall((:sincos, Base.Math.libm), Cvoid, (Cdouble, Ptr{Cdouble}, Ptr{Cdouble}), x, A, B)
    return Complex(B, A)
end

```

Sadly this will simply give me a segfault when compiled (it works inside julia). I suspect that the calls to Ref{CDouble}() amount to GC memory allocation calls. I would have thought that this could also be circumvented, since A and B are no arrays and it should be possible to pass memories to some scalar value. Sadly i did not manage to implement any version of my idea which would work even in normal julia (syntax errors).

---

_[View the full topic](https://discourse.julialang.org/t/staticcompiler-debugging-and-calling-basic-math-functions/93219)._
