https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116726
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Martin Uecker <uec...@gcc.gnu.org>: https://gcc.gnu.org/g:9227a64495d5594613604573b72422e8e3722fc5 commit r15-3745-g9227a64495d5594613604573b72422e8e3722fc5 Author: Martin Uecker <uec...@tugraz.at> Date: Tue Sep 17 11:37:29 2024 +0200 c: fix crash when checking for compatibility of structures [PR116726] When checking for compatibility of structure or union types in tagged_types_tu_compatible_p, restore the old value of the pointer to the top of the temporary cache after recursively calling comptypes_internal when looping over the members of a structure of union. While the next iteration of the loop overwrites the pointer, I missed the fact that it can be accessed again when types of function arguments are compared as part of recursive type checking and the function is entered again. PR c/116726 gcc/c/ChangeLog: * c-typeck.cc (tagged_types_tu_compatible_p): Restore value of the cache after recursing into comptypes_internal. gcc/testsuite/ChangeLog: * gcc.dg/pr116726.c: New test.