https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98840
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- https://www.youtube.com/watch?v=rHIkrotSwcc discusses exactly this problem. See also https://quuxplusone.github.io/blog/2018/05/02/trivial-abi-101/ This is not a GCC bug.