https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114410
--- Comment #7 from Cristian VOICA <cvoica at gmail dot com> --- I've found a flag that sounds closer to my needs: -Wcast-qual As the issue seems to me to come from the need to stay compatible with C I think this flag does a pretty decent job to hint at the problem. <source>: In function 'void bad_const_access(const A*)': <source>:24:18: warning: cast from type 'const Holder<std::__cxx11::basic_string<char> >*' to type 'std::string*' {aka 'std::__cxx11::basic_string<char>*'} casts away qualifiers [-Wcast-qual] 24 | std::cout << (std::string&)a->m_i << std::endl; //crash in gcc-13 but OK in gcc-12 | ^~~~~~~~~~~~~~~~~~~~ <source>:24:35: internal compiler error: in reference_binding, at cp/call.cc:2020 24 | std::cout << (std::string&)a->m_i << std::endl; //crash in gcc-13 but OK in gcc-12 | ^~~