https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118684
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:54bdeca3c6214485d15454df30183a56ad3e473b commit r15-7257-g54bdeca3c6214485d15454df30183a56ad3e473b Author: Richard Biener <rguent...@suse.de> Date: Tue Jan 28 16:20:30 2025 +0100 middle-end/118684 - wrongly aligned stack local during expansion The following fixes a not properly aligned stack temporary created during RTL expansion of a MEM_REF that we handle as a BIT_FIELD_REF whose base was allocated to a register but which was originally aligned to allow a larger load not trapping. While probably UB in C the vectorizer creates aligned accesses that might overread a (static) allocation because it is then known not to trap. PR middle-end/118684 * expr.cc (expand_expr_real_1): When expanding a reference based on a register and we end up needing a MEM make sure that's aligned as the original reference required. * gcc.dg/pr118684.c: New testcase.