I have a case in which a derivative is silently computed incorrectly. If I compile my code with the flag -Rpass=enzyme, the following remark is generated:
/Users/talamini1/dev/mfem/linalg/tensor.hpp:83:70: remark: Mismatched activity for: ret ptr %5, !dbg !3541 const val: %5 = getelementptr inbounds [3 x %"struct.mfem::future::tensor.0"], ptr %3, i64 0, i64 %4, !dbg !3540 [-Rpass=enzyme]
83 | MFEM_HOST_DEVICE const tensor< T, n1 >& operator[](int i) const { return values[i]; }
| ^
@wsmoses diagnosed the problem and has given me a workaround for my specific code (thanks!). The more general issue here is that in cases like this, where correctness cannot be guaranteed, compile-time warnings should be generated.