[Mono-dev] Possible compiler error regarding static unsafe initializers
Stephen Apostolopoulos
stapostol at gmail.com
Sat Aug 4 09:33:20 EDT 2007
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 =
(CallLists)GL.GetDelegateForExtensionMethod("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?
Thanks,
- Stephen A
--
In the beginning the Universe was created. This has made a lot of people
very angry and been widely regarded as a bad move - Douglas Adams
More information about the Mono-devel-list
mailing list