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

Constexpr math functions #275

Open
PaulXiCao opened this issue Dec 26, 2022 · 0 comments
Open

Constexpr math functions #275

PaulXiCao opened this issue Dec 26, 2022 · 0 comments

Comments

@PaulXiCao
Copy link
Contributor

Multiple functions in autodiff/forward/real/real.hpp are marked constexpr which does not align with the standard, e.g. exp, pow, ...

This is a non-standard gcc extension, see here.

Thus, the following example code compiles with gcc but not with clang nor msvc

#include <cmath>
int main(){ constexpr auto x = std::exp(1); }

You can try it live on godbolt here.

This problem will also occur when we try to apply those functions to real:

#include <autodiff/forward/real.hpp>
using namespace autodiff;

int main() { constexpr auto x = exp(real(1)); }

There are some drop-in replacements which support constexpr basic math functions. Maybe we should rely on one of those.

PS: I currently work on rewriting real.hpp abit and would remove the constexpr tag on those functions.

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

1 participant