https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105676
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-12 branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:96785885ceed34638d4b58e88cba6e6e8368c0e3 commit r12-9407-g96785885ceed34638d4b58e88cba6e6e8368c0e3 Author: Richard Biener <rguent...@suse.de> Date: Wed Dec 7 10:26:01 2022 +0100 ipa/105676 - pure attribute suggestion for const function When a function is declared const (even though it technically accesses memory), ipa-modref discovering pureness shouldn't end up suggesting that attribute. The following thus exempts 'const' functions from ipa_make_function_pure handling. PR ipa/105676 * ipa-pure-const.cc (ipa_make_function_pure): Skip also for functions already being const. * gcc.dg/pr105676.c: New testcase. (cherry picked from commit 45e09c2eb9c2bdd34ef777e06ddc9908dd0664f9)