[Mono-bugs] [Bug 40786][Nor] Changed - Accessibility checks on pointer types need special-casing

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Mon, 7 Apr 2003 05:07:40 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by lupus@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=40786

--- shadow/40786	Mon Apr  7 02:36:39 2003
+++ shadow/40786.tmp.1668	Mon Apr  7 05:07:40 2003
@@ -11,13 +11,13 @@
 AssignedTo: mono-bugs@ximian.com                            
 ReportedBy: webmaster@theratnerschool.org               
 QAContact: mono-bugs@ximian.com
 TargetMilestone: ---
 URL: 
 Cc: 
-Summary: Unsafe Code Will Not Compile on MCS
+Summary: Accessibility checks on pointer types need special-casing
 
 Description of Problem:
 When I compile the below code on mcs, it does not compile, but on csc it 
 does.
 
 using System;
@@ -85,6 +85,46 @@
 
 ------- Additional Comments From miguel@ximian.com  2003-04-07 02:36 -------
 This sounds strange.  This works with Mono/MCS.  
 
 Are you using Windows for this build maybe?  This might point to a
 discrepancy in our code when running in Mono.
+
+------- Additional Comments From lupus@ximian.com  2003-04-07 05:07 -------
+Yes, the code fails to compile when running mcs with the MS runtime.
+It looks like they set the accessibility of pointer types to NotPublic.
+I wrote a quick test and it looks like pointer and byref types get
+a 0 typeattribute (NotPublic) independently of the access flags of the
+underlying type, while array types gets the public flag even if the
+underlying type was not public.
+using System;
+using System.Reflection;
+
+struct T {
+
+	static void Main () {
+		Type a = typeof (int*);
+		Type b = typeof (T*);
+		Type c = Type.GetType ("System.Int32&");
+		Type d = Type.GetType ("T&");
+		Console.WriteLine ("int* access: {0}", (int)(a.Attributes &
+TypeAttributes.VisibilityMask));
+		Console.WriteLine ("T* access: {0}", (int)(b.Attributes &
+TypeAttributes.VisibilityMask));
+		Console.WriteLine ("int& access: {0}", (int)(c.Attributes &
+TypeAttributes.VisibilityMask));
+		Console.WriteLine ("T& access: {0}", (int)(d.Attributes &
+TypeAttributes.VisibilityMask));
+		Console.WriteLine ("int access: {0}", (int)(typeof(int).Attributes &
+TypeAttributes.VisibilityMask));
+		Console.WriteLine ("T access: {0}", (int)(typeof(T).Attributes &
+TypeAttributes.VisibilityMask));
+		Console.WriteLine ("int[] access: {0}",
+(int)(typeof(int[]).Attributes & TypeAttributes.VisibilityMask));
+		Console.WriteLine ("T[] access: {0}", (int)(typeof(T[]).Attributes &
+TypeAttributes.VisibilityMask));
+	}
+}
+
+So, this looks like yet another broken behaviour of the MS implementation.
+I guess mcs will have to special-case pointer and byref types 
+and consider them all as public.