Bug 321695 (MONO78982) - private CallingConvention with UnmanagedFunctionPointer bug
Summary: private CallingConvention with UnmanagedFunctionPointer bug
Status: RESOLVED MOVED
Alias: MONO78982
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Enhancement
Target Milestone: ---
Assignee: Raja R Harinath
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-01 01:27 UTC by David Hudson
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:04:59 UTC


---- Reported by jendave@yahoo.com 2006-07-31 18:27:40 MST ----

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);
    }
}
}



---- Additional Comments From jendave@yahoo.com 2006-08-01 10:44:51 MST ----

Sorry. It has been fixed in SVN - https://bugzilla.novell.com/show_bug.cgi?id=MONO78738

*** This bug has been marked as a duplicate of https://bugzilla.novell.com/show_bug.cgi?id=MONO78738 ***


Unknown operating system unknown. Setting to default OS "Other".
This bug was marked DUPLICATE in the database it was moved from.
    Changing resolution to "MOVED"