Skip to content

Properly inflate pointer types in inflate_generic_type. #1016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mono/metadata/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,14 @@ inflate_generic_type (MonoImage *image, MonoType *type, MonoGenericContext *cont
nt->data.generic_class = gclass;
return nt;
}
case MONO_TYPE_PTR: {
MonoType *nt, *inflated = inflate_generic_type (image, type->data.type, context, error);
if (!inflated || !mono_error_ok (error))
return NULL;
nt = mono_metadata_type_dup (image, type);
nt->data.type = inflated;
return nt;
}
default:
return NULL;
}
Expand Down
5 changes: 3 additions & 2 deletions mono/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ MCS_NO_UNSAFE = $(TOOLS_RUNTIME) $(CSC) -debug:portable \
-noconfig -nologo \
-nowarn:0162 -nowarn:0168 -nowarn:0219 -nowarn:0414 -nowarn:0618 \
-nowarn:0169 -nowarn:1690 -nowarn:0649 -nowarn:0612 -nowarn:3021 \
-nowarn:0197 $(PROFILE_MCS_FLAGS)
-nowarn:0197 -langversion:7.3 $(PROFILE_MCS_FLAGS)
MCS_NO_LIB = $(MCS_NO_UNSAFE) -unsafe

MCS = $(MCS_NO_LIB)
Expand Down Expand Up @@ -530,7 +530,8 @@ TESTS_CS_SRC= \
bug-59281.cs \
init_array_with_lazy_type.cs \
weak-fields.cs \
threads-leak.cs
threads-leak.cs \
generic-unmanaged-constraint.cs

if AMD64
TESTS_CS_SRC += async-exc-compilation.cs finally_guard.cs finally_block_ending_in_dead_bb.cs
Expand Down
17 changes: 17 additions & 0 deletions mono/tests/generic-unmanaged-constraint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;

unsafe class Program
{
public static int Main(string[] args)
{
return (int)(IntPtr)Generic<int>.GetPtr();
}
}

unsafe class Generic<T> where T : unmanaged
{
public static T* GetPtr()
{
return (T*)null;
}
}