https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96730
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-10 branch has been updated by Martin Jambor <jamb...@gcc.gnu.org>: https://gcc.gnu.org/g:e57cdbca52df908a48bbf92c64d50dd46f483de9 commit r10-8661-ge57cdbca52df908a48bbf92c64d50dd46f483de9 Author: Martin Jambor <mjam...@suse.cz> Date: Tue Aug 25 16:11:56 2020 +0200 sra: Bail out when encountering accesses with negative offsets (PR 96730) I must admit I was quite surprised to see that SRA does not disqualify an aggregate from any transformations when it encounters an offset for which get_ref_base_and_extent returns a negative offset. It may not matter too much because I sure hope such programs always have undefined behavior (SRA candidates are local variables on stack) but it is probably better not to perform weird transformations on them as build ref model with the new build_reconstructed_reference function currently happily do for negative offsets (they just copy the existing expression which is then used as the expression of a "propagated" access) and of course the compiler must not ICE (as it currently does because the SRA forest verifier does not like the expression). gcc/ChangeLog: 2020-08-24 Martin Jambor <mjam...@suse.cz> PR tree-optimization/96730 * tree-sra.c (create_access): Disqualify any aggregate with negative offset access. (build_ref_for_model): Add assert that offset is non-negative. gcc/testsuite/ChangeLog: 2020-08-24 Martin Jambor <mjam...@suse.cz> PR tree-optimization/96730 * gcc.dg/tree-ssa/pr96730.c: New test. (cherry picked from commit 556600286dd312d3ddf3d673a8579576862663e3)