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

f(x::Real) = f(float(x)) leads to stackoverflow #366

Closed
cossio opened this issue Oct 9, 2018 · 3 comments
Closed

f(x::Real) = f(float(x)) leads to stackoverflow #366

cossio opened this issue Oct 9, 2018 · 3 comments

Comments

@cossio
Copy link
Contributor

cossio commented Oct 9, 2018

Many definitions follow this pattern:

f(x::AbstractFloat) = 2x # any computation here
f(x::Real) = f(float(x))

But then:

julia> ForwardDiff.derivative(f, 1.)
ERROR: StackOverflowError:
Stacktrace:
 [1] f(::ForwardDiff.Dual{ForwardDiff.Tag{typeof(f),Float64},Float64,1}) at ./REPL[3]:1 (repeats 80000 times)

Because float(Dual) gives Dual which is not AbstractFloat. Is there a way around this?

@cossio
Copy link
Contributor Author

cossio commented Oct 9, 2018

I did not realize this was being discussed elsewhere

JuliaLang/julia#26552
#261
#324
musm/SLEEF.jl#11

@cossio cossio closed this as completed Oct 9, 2018
@DilumAluthge
Copy link
Member

DilumAluthge commented Oct 9, 2018 via email

@DilumAluthge
Copy link
Member

DilumAluthge commented Oct 9, 2018 via email

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

2 participants