[Bug c++/126860] [14/15/16/17 Regression] ICE when calling a function pointer data member with a qualified-id from a dependent base class template

"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126860

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <[email protected]>:

https://gcc.gnu.org/g:0e74517b70d06105bd40c8caa6dc192b4af3ccff

commit r17-3301-g0e74517b70d06105bd40c8caa6dc192b4af3ccff
Author: Patrick Palka <[email protected]>
Date:   Fri Aug 14 14:33:46 2026 -0400

    c++: ICE w/ maybe_warn_nodiscard on non-dep call [PR123495, PR126860]

    Another latent issue uncovered by the NON_DEPENDENT_EXPR removal.
    cp_get_fndecl_from_callee, called from maybe_warn_nodiscard, tries to
    fold the templated callee via constant evaluation, but constant
    evaluation expects non-templated trees.  So use fold_non_dependent_expr
    which instantiates templated trees beforehand.  We could use f_n_d_init
    also but there should be no difference for a result that doesn't end up
    as NULL_TREE.

            PR c++/123495
            PR c++/126860

    gcc/cp/ChangeLog:

            * cvt.cc (cp_get_fndecl_from_callee): Use fold_non_dependent_expr
            instead of maybe_constant_init.

    gcc/testsuite/ChangeLog:

            * g++.dg/template/non-dependent36.C: New test.
            * g++.dg/template/non-dependent37.C: New test.

    Reviewed-by: Jason Merrill <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.