[Mono-bugs] [Bug 78982][Wis] New - private CallingConvention with UnmanagedFunctionPointer bug

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Jul 31 18:27:41 EDT 2006


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 jendave at yahoo.com.

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

--- shadow/78982	2006-07-31 18:27:41.000000000 -0400
+++ shadow/78982.tmp.31348	2006-07-31 18:27:41.000000000 -0400
@@ -0,0 +1,142 @@
+Bug#: 78982
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: jendave at yahoo.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: private CallingConvention with UnmanagedFunctionPointer bug
+
+Hi,
+
+I found a bug using Mono 1.13.8 on Windows XP using gmcs.
+
+This code will not compile:
+
+----------------------------------------
+using System;
+using System.Runtime.InteropServices;
+
+namespace Test.Bug
+{
+    public sealed class Test
+    {
+        private const CallingConvention CALLING_CONVENTION = 
+CallingConvention.Cdecl;
+
+        [UnmanagedFunctionPointer(CALLING_CONVENTION)]
+        public delegate int CallingConventionBug(IntPtr ptr);
+    }
+}
+----------------------------------------
+
+You get this set of compilation errors.
+------------------------------
+[csc] Unhandled Exception: System.NullReferenceException: Object 
+reference not set to an instance of an object
+                  [csc] in <0x00010> 
+Mono.CSharp.TypeManager:IsPrivateAccessible (System.Type type, 
+System.Type parent)
+                  [csc] in <0x002d0> 
+Mono.CSharp.TypeManager+Closure:Filter (System.Reflection.MemberInfo m, 
+System.Object filter_criteria)
+                  [csc] in (wrapper delegate-invoke) 
+System.MulticastDelegate:invoke_bool_MemberInfo_object 
+(System.Reflection.MemberInfo,object)
+                  [csc] in <0x001e5> Mono.CSharp.MemberCache:FindMembers 
+(MemberTypes mt, BindingFlags bf, System.String name, 
+System.Reflection.MemberFilter filter, System.Object criteria)
+                  [csc] in <0x000be> 
+Mono.CSharp.TypeManager:MemberLookup_FindMembers (System.Type t, 
+MemberTypes mt, BindingFlags bf, System.String name, System.Boolean 
+used_cache)
+                  [csc] in <0x001ad> 
+Mono.CSharp.TypeManager:RealMemberLookup (System.Type invocation_type, 
+System.Type qualifier_type, System.Type queried_type, MemberTypes mt, 
+BindingFlags original_bf, System.String name, IList almost_match)
+                  [csc] in <0x0001f> Mono.CSharp.TypeManager:MemberLookup 
+(System.Type invocation_type, System.Type qualifier_type, System.Type 
+queried_type, MemberTypes mt, BindingFlags original_bf, System.String 
+name, IList almost_match)
+                  [csc] in <0x00038> Mono.CSharp.Expression:MemberLookup 
+(Mono.CSharp.EmitContext ec, System.Type container_type, System.Type 
+qualifier_type, System.Type queried_type, System.String name, MemberTypes 
+mt, BindingFlags bf, Location loc)
+                  [csc] in <0x00022> Mono.CSharp.Expression:MemberLookup 
+(Mono.CSharp.EmitContext ec, System.Type queried_type, System.String 
+name, Location loc)
+                  [csc] in <0x001b0> 
+Mono.CSharp.SimpleName:DoSimpleNameResolve (Mono.CSharp.EmitContext ec, 
+Mono.CSharp.Expression right_side, Boolean intermediate)
+                  [csc] in <0x00030> 
+Mono.CSharp.SimpleName:SimpleNameResolve (Mono.CSharp.EmitContext ec, 
+Mono.CSharp.Expression right_side, Boolean intermediate)
+                  [csc] in <0x00014> Mono.CSharp.SimpleName:DoResolve 
+(Mono.CSharp.EmitContext ec, Boolean intermediate)
+                  [csc] in <0x000d2> Mono.CSharp.Expression:Resolve 
+(Mono.CSharp.EmitContext ec, ResolveFlags flags)
+                  [csc] in <0x00012> Mono.CSharp.Expression:Resolve 
+(Mono.CSharp.EmitContext ec)
+                  [csc] in <0x0014d> Mono.CSharp.Argument:Resolve 
+(Mono.CSharp.EmitContext ec, Location loc)
+                  [csc] in <0x00275> 
+Mono.CSharp.Attribute:ResolveArguments (Mono.CSharp.EmitContext ec)
+                  [csc] in <0x0015b> Mono.CSharp.Attribute:Resolve 
+(Mono.CSharp.EmitContext ec)
+                  [csc] in <0x00064> Mono.CSharp.Attribute:Emit 
+(Mono.CSharp.EmitContext ec, Mono.CSharp.Attributable ias, 
+System.Collections.Specialized.ListDictionary emitted_attr)
+                  [csc] in <0x0009c> Mono.CSharp.Attributes:Emit 
+(Mono.CSharp.EmitContext ec, Mono.CSharp.Attributable ias)
+                  [csc] in <0x0003d> Mono.CSharp.Delegate:Emit ()
+                  [csc] in <0x00ecd> Mono.CSharp.TypeContainer:EmitType ()
+                  [csc] in <0x00226> Mono.CSharp.RootContext:EmitCode ()
+                  [csc] in <0x00a9f> Mono.CSharp.Driver:MainDriver 
+(System.String[] args)
+                  [csc] in <0x00051> Mono.CSharp.Driver:Main 
+(System.String[] args)
+--------------------------------
+-- However, if you mark the const CallingConvention as public, the code 
+compiles fine.
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Test.Bug
+{
+    public sealed class Test
+    {
+        public const CallingConvention CALLING_CONVENTION = 
+CallingConvention.Cdecl;
+
+        [UnmanagedFunctionPointer(CALLING_CONVENTION)]
+        public delegate int CallingConventionBug(IntPtr ptr);
+    }
+
+-- Or if you explicitly put the callingConvention in the attribute, the 
+code compiles fine.
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Test.Bug
+{
+    public sealed class Test
+    {
+        //private const CallingConvention CALLING_CONVENTION = 
+CallingConvention.Cdecl;
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate int CallingConventionBug(IntPtr ptr);
+    }
+}
+}


More information about the mono-bugs mailing list