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

Dereferencing of input parameters doesn't work in forward mode #972

Closed
guitargeek opened this issue Jul 8, 2024 · 0 comments · Fixed by #975
Closed

Dereferencing of input parameters doesn't work in forward mode #972

guitargeek opened this issue Jul 8, 2024 · 0 comments · Fixed by #975
Assignees
Milestone

Comments

@guitargeek
Copy link
Contributor

guitargeek commented Jul 8, 2024

This is related to #961, only that now the dereferenced array is a parameter to the function.

Reproducer:

// Compile with clang++ -std=c++11 -fplugin=install/clad.so -I./install/include cladIssue.cxx -o cladIssue

#include "clad/Differentiator/Differentiator.h"

#include <iostream>
#include <vector>

double wrapper(double* params, double const* constants) {
   double c0 = *constants;
   return params[0] * c0;
}

int main()
{
   auto diff = clad::differentiate(wrapper, "params[0]"); // doesn't work
   auto grad = clad::gradient(wrapper, "params"); // works!

   double x = 2.0;
   double y = 2.0;
   double result = 0.0;
   grad.execute(&x, &y, &result);

   std::cout << result << std::endl;
   std::cout << diff.execute(&x, &y) << std::endl;
}

Compiler output:

error: indirection requires pointer operand ('int' invalid)
1 error generated.

I'm using LLVM and Clang 16 to build clad standalone (see #973).

@vgvassilev vgvassilev added this to the v1.6 milestone Jul 8, 2024
vaithak added a commit to vaithak/clad that referenced this issue Jul 9, 2024
vaithak added a commit to vaithak/clad that referenced this issue Jul 9, 2024
vaithak added a commit to vaithak/clad that referenced this issue Jul 11, 2024
vaithak added a commit to vaithak/clad that referenced this issue Jul 11, 2024
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.

3 participants