https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106921
Tomasz Kapela <tkapela at poczta dot fm> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tkapela at poczta dot fm --- Comment #6 from Tomasz Kapela <tkapela at poczta dot fm> --- I think I encounter the same issue with my library code. Simplified example is here https://github.com/tomasz-kapela/DMapProblem Incorrect output appears only with -O2 flag on GCC 10, 11, 12. Also turning off partial inlining optimalization solves the problem: -O2 -fno-partial-inlining I have checked that on GCC 8.4 with -O2 the output is correct. Replacing lines 75-78 in include/capd/autodiff/EvalSub.h: if(coeffNo) result[coeffNo] = -right[coeffNo]; else *result = *left - *right; with result[coeffNo] = (coeffNo!=0) ? -right[coeffNo] : *left - *right; produce correct output. Should I post it as a separate bug report?