[Mono-dev] Possible compiler error regarding static unsafe initializers
marek.safar at seznam.cz
Sat Aug 4 10:24:53 EDT 2007
It seems to me like a bug. Please create a bug report with reproducible
> The following code compiles with the .Net 2.0 csc, but fails on gmcs 1.2.4
> (Linux x64, vanilla compilation):
> internal unsafe delegate void CallLists(Int32 n, GL.Enums.ListNameType
> type, void* lists);
> internal unsafe static CallLists glCallLists =
> typeof(CallLists)) ??
> new CallLists(Imports.CallLists);
> ^(produces the error below)
> "[csc] [...]/OpenTK/OpenGL/Bindings/GLDelegates.cs(23,137): error CS0214:
> Pointers and fixed size buffers may only be used in an unsafe context"
> The error position (23,137) refers to the "new
> CallLists(Imports.CallLists);" part. The code is compiled with the /unsafe
> flag, and the context, as far as I can see, *is* unsafe ("internal unsafe
> This is part of the initialization logic of Tao.OpenGl. The idea is to
> initialize the glCallLists delegate either with a dynamically extracted
> entry point (GetDelegateForExtensionMethod), or, if the entry point is not
> dynamically exported, with the static entry point produced by a DllImport.
> While this issue can be worked around (either using reflection, or using
> 'safe' IntPtrs instead of raw pointers), I would like to know whether this
> is a genuine gmcs error, which should be reported, or a standard violation
> on the .Net csc side.
> Anyone have any ideas?
> - Stephen A
More information about the Mono-devel-list