https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98662
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- So is this a rejects-valid as well? The assert suggests the return value and the diagnostic without checking is wrong: > g++-11 t.C -c t.C: In instantiation of 'int f(S<int>)': t.C:16:10: required from here t.C:6:14: error: 'int S<const int>::j' is protected within this context 6 | (void) y.j; | ~~^ t.C:12:7: note: declared protected here 12 | int j; | ^