https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127301
--- Comment #1 from Drea Pinski <pinskia at gcc dot gnu.org> --- You missed the first part: "The const attribute prohibits a function from reading objects that affect its return value between successive invocations." Note the reading part there. The C++ standard defines what is a read too.
