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

Clad crashes when a function has a default object argument #1118

Open
gojakuch opened this issue Oct 15, 2024 · 0 comments
Open

Clad crashes when a function has a default object argument #1118

gojakuch opened this issue Oct 15, 2024 · 0 comments

Comments

@gojakuch
Copy link
Collaborator

it doesn't matter if the argument;s default value is overwritten with another value or not -- Clad crashes anyway. it's important to prevent Clad from crashing in this case even if we don't support the default arguments in general yet (#1028), since some STL (#1067) and Kokkos functionality depends on this.

reproducer:

#include "clad/Differentiator/Differentiator.h"
#include "clad/Differentiator/STLBuiltins.h"
#include <iostream>
#include <string>

#define show(x) std::cout << #x << ": " << x << "\n";

double g(double x, const std::string &s = "default string") {
    return x;
}

double fn(double u, double v) {
    double x = g(u);
    return x;
}

int main() {
    auto d_fn = clad::gradient(fn);
    double u = 3, v = 5;
    double du, dv;
    du = dv = 0;
    show(fn(u, v));
    d_fn.execute(u, v, &du, &dv);
    show(du);
    show(dv);
}
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