Skip to content

Commit

Permalink
Fix a bug with incorrect indices in the rev sweep.
Browse files Browse the repository at this point in the history
  • Loading branch information
PetroZarytskyi committed Jan 11, 2024
1 parent 6de0fb0 commit c2aa94c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
BuildArraySubscript(BaseDiff.getRevSweepAsExpr(), reverseIndices);
Expr* target = BaseDiff.getExpr_dx();
if (!target)
return cloned;
return StmtDiff(cloned, nullptr, nullptr, valueForRevSweep);
Expr* result = nullptr;
Expr* forwSweepDerivative = nullptr;
if (utils::isArrayOrPointerType(target->getType())) {
Expand Down
6 changes: 4 additions & 2 deletions test/Gradient/Assignments.C
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// RUN: %cladclang %s -I%S/../../include -oReverseAssignments.out 2>&1 | FileCheck %s
/// FIXME: `-Wno-unused-value` is needed to suppress the warning
/// produced by `f21`. We have to figure out where it comes from.
// RUN: %cladclang %s -Wno-unused-value -I%S/../../include -oReverseAssignments.out 2>&1 | FileCheck %s
// RUN: ./ReverseAssignments.out | FileCheck -check-prefix=CHECK-EXEC %s
// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oReverseAssignments.out
// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -Wno-unused-value -I%S/../../include -oReverseAssignments.out
// RUN: ./ReverseAssignments.out | FileCheck -check-prefix=CHECK-EXEC %s
//CHECK-NOT: {{.*error|warning|note:.*}}

Expand Down

0 comments on commit c2aa94c

Please sign in to comment.