C++: Fixed internal compiler error with invalid template argument.
Addresses an ICE caused by temporary objects in template argument deduction by skipping a problematic check for ignored declarations.
An internal compiler error (ICE) occurred when processing invalid template arguments due to a faulty assertion. The assertion checked for specific properties of template arguments, but failed when temporary objects were involved. This commit relaxes the assertion to allow ignored declarations, resolving the ICE. New test cases cover the reported issue.
In Details
This commit modifies cp/pt.cc to handle temporary objects in template argument deduction more gracefully by allowing DECL_IGNORED_P in invalid_tparm_referent_p. The original patch (r14-8189) introduced an assert that triggered with temporary objects created by create_temporary_var, specifically reference temporaries and compound literal temporaries. The fix avoids the assertion for ignored declarations. The issue is exposed via g++.dg/cpp1z/nontype-auto27.C, g++.dg/cpp1z/nontype-auto28.C, and g++.dg/cpp2a/nontype-class75.C.
For Context
Template argument deduction in C++ is the process where the compiler infers the types of template parameters based on how the template is used. This commit fixes a bug in this deduction process that could lead to a compiler crash (internal compiler error, or ICE) when encountering certain types of invalid template arguments. Specifically, the issue involved temporary objects. The fix prevents the crash and improves compiler robustness.