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

Static qualifier is dropped when differentiating methods with out-of-line definitions in forward mode #951

Closed
PetroZarytskyi opened this issue Jun 18, 2024 · 0 comments · Fixed by #953

Comments

@PetroZarytskyi
Copy link
Collaborator

PetroZarytskyi commented Jun 18, 2024

Reproducer:

/// The original code
class A {
  public:
  static double fun(double x);
};

double A::fun(double x) {
  return x;
}

int main() {
  clad::differentiate(A::fun);
  return 0;
}

The bit of code above is differentiated as

/// The differentiated code
double fun_darg0(double x) {      // <-- Notice: no static qualifier
    double _d_x = 1;
    return _d_x;
}

Whereas using an in-line definition

/// The original code
class A {
  public:
  static double fun(double x) {
    return x;
  }
};

int main() {
  clad::differentiate(A::fun);
  return 0;
}

results in the expected behavior

/// The differentiated code
static double fun_darg0(double x) {
    double _d_x = 1;
    return _d_x;
}
PetroZarytskyi added a commit to PetroZarytskyi/clad that referenced this issue Jun 19, 2024
PetroZarytskyi added a commit to PetroZarytskyi/clad that referenced this issue Jun 19, 2024
when cloning functions to copy all of the qualifiers.
Fixes vgvassilev#951
PetroZarytskyi added a commit to PetroZarytskyi/clad that referenced this issue Jun 19, 2024
when cloning functions to copy all of the qualifiers.
Fixes vgvassilev#951
PetroZarytskyi added a commit to PetroZarytskyi/clad that referenced this issue Jun 19, 2024
When cloning functions we should clone
the storage class of the canonical declaration
in order to retain all of the qualifiers.
Fixes vgvassilev#951
ovdiiuv pushed a commit to ovdiiuv/clad that referenced this issue Jun 23, 2024
When cloning functions we should clone
the storage class of the canonical declaration
in order to retain all of the qualifiers.
Fixes vgvassilev#951
ovdiiuv pushed a commit to ovdiiuv/clad that referenced this issue Jun 23, 2024
When cloning functions we should clone
the storage class of the canonical declaration
in order to retain all of the qualifiers.
Fixes vgvassilev#951
ovdiiuv pushed a commit to ovdiiuv/clad that referenced this issue Jun 23, 2024
When cloning functions we should clone
the storage class of the canonical declaration
in order to retain all of the qualifiers.
Fixes vgvassilev#951
ovdiiuv pushed a commit to ovdiiuv/clad that referenced this issue Jun 24, 2024
When cloning functions we should clone
the storage class of the canonical declaration
in order to retain all of the qualifiers.
Fixes vgvassilev#951
ovdiiuv pushed a commit to ovdiiuv/clad that referenced this issue Jun 24, 2024
When cloning functions we should clone
the storage class of the canonical declaration
in order to retain all of the qualifiers.
Fixes vgvassilev#951
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.

1 participant