mirror of
https://gcc.gnu.org/git/gcc.git
synced 2026-02-22 20:01:22 -05:00
c++: Fix nullptr deref [pr97460[
My changes to friend handling meant that there are now cases where a friend doesn't get a lang-specific object. So we need to check there is one before looking inside it. PR c++/97460 gcc/cp/ * pt.c (push_template_decl): Check DECL_LANG_SPECIFIC in friend case. gcc/testsuite/ * g++.dg/template/pr97460.C: New.
This commit is contained in:
@@ -5877,7 +5877,8 @@ push_template_decl (tree decl, bool is_friend)
|
||||
|| TREE_CODE (ctx) == FUNCTION_DECL
|
||||
|| (CLASS_TYPE_P (ctx) && TYPE_BEING_DEFINED (ctx))
|
||||
|| (TREE_CODE (decl) == TYPE_DECL && LAMBDA_TYPE_P (TREE_TYPE (decl)))
|
||||
|| (is_friend && !DECL_TEMPLATE_INFO (decl)))
|
||||
|| (is_friend && !(DECL_LANG_SPECIFIC (decl)
|
||||
&& DECL_TEMPLATE_INFO (decl))))
|
||||
{
|
||||
if (DECL_LANG_SPECIFIC (decl)
|
||||
&& DECL_TEMPLATE_INFO (decl)
|
||||
|
||||
9
gcc/testsuite/g++.dg/template/pr97460.C
Normal file
9
gcc/testsuite/g++.dg/template/pr97460.C
Normal file
@@ -0,0 +1,9 @@
|
||||
// PR 97460
|
||||
// ICE, null dereference
|
||||
|
||||
class io_context {
|
||||
template <int> class basic_executor_type;
|
||||
};
|
||||
template <int> class io_context::basic_executor_type {
|
||||
template <int> friend class basic_executor_type;
|
||||
};
|
||||
Reference in New Issue
Block a user