https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80710
--- Comment #1 from dr.markus.hoffmann at gmx dot de <dr.markus.hoffmann at gmx dot de> --- This example wants to show, that the optimizer destroys compatibility to the ABI, either with optimizing something in the calling procedure (likely) or in the called function. The same error happens, when test2 is in a .so library and dynamically linked to the main program at runtime. Since the main program does not know the function prototype at compile time it has to rely on calling it in an ABI-compatible way.