https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117966
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- The __glibcxx_requires_valid_range check was added in r12-3272-gef7becc9c8a488 so that will be why it compiles when you preprocess with GCC 11. As far as I can tell, everything involved should be a constant expression.