[Mono-list] (Generics) type parameters and pointers

Martin Baulig martin@ximian.com
Wed, 28 Jul 2004 15:26:04 +0200

On Sun, 2004-07-25 at 13:51 +0000, Alan Jenkins wrote:
> I know type parameters cannot be pointers - ArrayList<int*> is not permitted - 
> but I haven't been able to a definitive statement regarding whether pointers 
> to the type of a parameter is permitted, e.g.
> struct Pointer <T> {
> 	T* value;
> }
> Currently, gmcs will complain that it can't find the type "T*", but I would 
> have thought it would be relatively easy to allow, given that the following 
> is allowed.
> struct Array <T> {
> 	T[] value;
> }


according to the spec (25.2), you can only take a pointer of an
unmanaged type, not a managed one.

csc says

> $ csc /unsafe C.cs
> Microsoft (R) Visual C# .NET Compiler version 8.00.40607.16
> for Microsoft (R) Windows (R) .NET Framework version 2.0.40607
> Copyright (C) Microsoft Corporation 2001-2003. All rights reserved.
> C.cs(3,5): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('T')
> C.cs(1,23): (Location of symbol related to previous error)

I'll fix gmcs to report the same error.