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

Unnecessary warning when differentiating a function that mutates its array arg #1035

Open
ZeptoStarling opened this issue Aug 8, 2024 · 0 comments · May be fixed by #1062
Open

Unnecessary warning when differentiating a function that mutates its array arg #1035

ZeptoStarling opened this issue Aug 8, 2024 · 0 comments · May be fixed by #1062
Assignees

Comments

@ZeptoStarling
Copy link
Contributor

double example(double x, double *y)
{
    y[0] = 3;
    return x * y[0];
}

int main()
{
    double x = 10.0;
    double y[3] = {7.0, 4.6, 6.3};
    auto ex = clad::differentiate(example, "x");
    ex.dump();
    std::cout << ex.execute(x, y) << std::endl;
}

on Clad version 1.8~dev this gives a compilation warning:

warning: derivative of an assignment attempts to assign to unassignable expr, assignment ignored
    y[0] = 3;
           ^
1 warning generated.

This warning is a little confusing and could be interpreted as the code not working as intended, when in reality it produces expected results.

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

Successfully merging a pull request may close this issue.

2 participants