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

undefined behavior in fast_expf #10

Open
Dr15Jones opened this issue Jul 16, 2019 · 2 comments
Open

undefined behavior in fast_expf #10

Dr15Jones opened this issue Jul 16, 2019 · 2 comments

Comments

@Dr15Jones
Copy link

While using VDT while using the gcc undefined behavior compiles flag, we get the report

vdt/exp.h:144:38: runtime error: left shift of negative value -109

Which is
https://github.com/dpiparo/vdt/blob/master/include/exp.h#L144

The happens when calling vdt::fast_expf with the value

vdt::fast_expf (initial_x=-163.483994)

The C++ standard does say that left shifting a negative number is undefined.

@Dr15Jones
Copy link
Author

It looks like the simplest solution would be to check the bounds of initial_x at the beginning of the function, instead of at the end:
https://github.com/dpiparo/vdt/blob/master/include/exp.h#L147
and return immediately.

@VinInn
Copy link
Collaborator

VinInn commented Jul 16, 2019 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