https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126552
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- That is a user error. For C++ the language requires such handling of const variables initialized with constant expressions, for C allows it. So, if you don't want that behavior, either drop the const keyword in those cases, or for GCC 16+ use the hard register constraints.
