EnzymeAD/Enzyme

incorrect derivative of function that returns struct

samuelpmish opened this issue · 2 comments

https://fwd.gymni.ch/vKIfPx

It seems like some versions of clang are getting the right answers, but others aren't

Update: I was asked to try refactoring the wrapper to return by-reference instead of by-value, but that doesn't seem to have changed the output:

https://fwd.gymni.ch/qIWjto

It's also worth noting that I may just be using __enzyme_fwddiff incorrectly!

I showed this to @jandrej and he noticed an important detail: the results are correct when compiling with -O2, but incorrect without it, so maybe it's another inlining issue (and if so, which functions should be forced to inline?)