https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65002
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Sure, the __attribute__((const)) looks very much wrong to me, as it returns what the reference points, it necessarily reads memory and therefore is at most pure, but certainly not const. But, we must not ICE even on invalid or questionable code. And misplaced const attribute isn't something we should hard error on, perhaps warn (I think there is some PR about that and it is definitely non-trivial).