https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106502
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- I noticed this by adding a printf statement to the const function for temporary debugging purposes, which is obviously incorrect and not a problem for real code. It's not observable that it gets called more than once, it just makes unoptimized code a bit slower.