https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113031
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Nathaniel Shead <nsh...@gcc.gnu.org>: https://gcc.gnu.org/g:39f9c426f58448d6df340cdccd84e05721a20921 commit r14-6619-g39f9c426f58448d6df340cdccd84e05721a20921 Author: Nathaniel Shead <nathanielosh...@gmail.com> Date: Sat Dec 16 10:59:03 2023 +1100 c++: Fix unchecked use of CLASSTYPE_AS_BASE [PR113031] My previous commit (naively) assumed that a TREE_CODE of RECORD_TYPE or UNION_TYPE was sufficient for optype to be considered a "class type". However, this does not account for e.g. template type parameters of record or union type. This patch corrects to check for CLASS_TYPE_P before checking for as-base conversion. PR c++/113031 gcc/cp/ChangeLog: * constexpr.cc (cxx_fold_indirect_ref_1): Check for CLASS_TYPE before using CLASSTYPE_AS_BASE. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/pr113031.C: New test. Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>