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

Incorrect cloning of CXX operator overloads with non-reference return types #683

Closed
vgvassilev opened this issue Dec 19, 2023 · 3 comments
Closed
Milestone

Comments

@vgvassilev
Copy link
Owner

#include "clad/Differentiator/Differentiator.h"
#include <iostream>
#define show(x) std::cout << #x << ": " << x << "\n";

class Identity {
    public:
    double operator()(double u) { return u; }
};

template<class F>
double algo(F f, double x) {
    double val = f(x);
    return val * val;
}

int main() {
    auto grad = clad::gradient(algo<Identity>);
    double x=3, dx=0;
    Identity di;
    grad.execute(Identity(), x, &di, &dx);
    show(dx); // This prints: x: 6
}

See #637 (comment)

@vgvassilev vgvassilev added this to the v1.4 milestone Dec 19, 2023
@guitargeek
Copy link
Contributor

Hi! Sorry, I think I got something wrong when I made my comment, and this is actually the problem that was fixed by:
#645

@vgvassilev
Copy link
Owner Author

@guitargeek so we can close this one?

@guitargeek
Copy link
Contributor

Yes. Sorry, I confused something here!

@vgvassilev vgvassilev closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2023
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