https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102513
--- Comment #11 from Martin Jambor <jamborm at gcc dot gnu.org> --- I am very well aware that my patch was just a mitigation, not something that would avoid the problem under all circumstances. We can attempt to look at array access indices during the summary creation phase and save constraints on parameters in order to not create the clones. But even then, inlining and late optimizations can expose such invalid array accesses in the clones that we still create and that are practically impossible to know about at IPA-CP time. It would be great if we finally invented a way to communicate to users that a warning comes from a function specialized for a given context or inlined at a particular point. Then the user would see that compiler created some dead code and might think it is stupid, but would at least know what is going on (see PR 102061 and the discussion in PR 60761). Limiting cloning if we know from VR that we should, like my patch does, is still a good thing to do, I think.