Comment #0 by flamaros.xavier — 2018-05-04T21:44:15Z
I am trying do a custom opengl32.dll, all my code is already tagged with @nogc, but when I enable the -betterC option I get the following error that isn't really helpful.
The error comes from the function destroy implementation, but I can't figure out from where it is called in my code.
------ Début de la génération : Projet : opengl32, Configuration : debug Win32 ------
Building D:\Dev\Personal\ToVulkanPoc\bin\opengl32.dll...
D:\Softs\D\dmd2\windows\bin\..\..\src\druntime\import\object.d(3035): Error: `TypeInfo` cannot be used with -betterC
Building D:\Dev\Personal\ToVulkanPoc\bin\opengl32.dll failed!
Details saved as "file://D:\Dev\Personal\ToVulkanPoc\opengl32\.dub\obj\debug\dummy\dummy\opengl32\opengl32.buildlog.html"
========== Génération : 0 a réussi, 1 a échoué, 1 mis à jour, 0 a été ignoré ==========
Comment #1 by greensunny12 — 2018-05-07T14:02:46Z
It would be really helpful if you could post your code or a snippet that reproduces the error.
You can use digger for reducing it: https://github.com/CyberShadow/Digger
Are you by chance using classes somewhere?
Comment #2 by dlang-bugzilla — 2018-05-07T16:42:44Z
Comment #3 by flamaros.xavier — 2018-05-07T18:16:29Z
Created attachment 1692
source code that produce the error
I don't have any class.
api_entry.d file is generated, so all functions are similar, only wglChoosePixelFormat and wglDescribePixelFormat are different from others.
The dll_entry.d file could be removed if the -betterC worked.
forward_initialization.d contains some specific code to override the wglChoosePixelFormat and wglDescribePixelFormat behavior.
The archive also contains the dub file.
I'll try DustMite later, but actually my code is pretty minimal, except for the generated file, because I need to export all opengl32 symbols to be able to begin tests (else applications will complains about missing APIs).
Comment #4 by slavo5150 — 2018-05-08T02:14:31Z
I tried looking through the attachment, but there's just too much generated code and it also imports other modules which may contain the offending code.
I tried doing a `dub build` on the attachment, but was left with the following error:
src\api_entry.d(428,8): Error: module `functions` is in file 'opengl_api\functions.d' which cannot be read
So I don't have any way to reproduce the problem. A dustmite reduction would be ideal.
This may also be a duplicate of issue 18493, depending on where the precise offending code is.
Comment #5 by flamaros.xavier — 2018-05-08T11:07:55Z
Created attachment 1693
Complete project
I tried dustmite with the command line in a git bash window :
dustmite --force -no-redirect .. "dub build 2>&1 | grep -qF 'TypeInfo cannot be used with -betterC'"
I am getting the error :
object.Exception@DustMite\dustmite.d(271): Initial test fails (try using --no-redirect for details)
Comment #6 by greensunny12 — 2018-05-08T11:41:41Z
> object.Exception@DustMite\dustmite.d(271): Initial test fails (try using --no-redirect for details)
Then use --no-direct (or the tester command in standalone) to see why it failed.
Comment #7 by slavo5150 — 2018-05-08T11:47:14Z
The problem is this code in object.d:
void destroy(T)(ref T obj) if (is(T == struct))
{
_destructRecurse(obj);
() @trusted {
auto buf = (cast(ubyte*) &obj)[0 .. T.sizeof];
auto init = cast(ubyte[])typeid(T).initializer();
if (init.ptr is null) // null ptr means initialize to 0s
buf[] = 0;
else
buf[] = init[];
} ();
}
The call to `typeid` needs to return a `TypeInfo` instance. Is there a way to get the initializer at compile-time without a runtime call to `typeid`?
Comment #8 by flamaros.xavier — 2018-05-08T12:13:38Z
dustmite with the --no-redirect option give me the output :
Loading ..\common\opengl_api\arb.d
Loading ..\common\opengl_api\constants.d
Loading ..\common\opengl_api\ext.d
Loading ..\common\opengl_api\functions.d
Loading ..\common\opengl_api\types.d
Loading ..\common\opengl_api\wgl.d
Loading ..\common\opengl_api\wglext.d
Loading ..\common\utils\ctfe.d
Loading ..\opengl32\.dub\dub.json
Loading ..\opengl32\dub.sdl
Loading ..\opengl32\dub.selections.json
Loading ..\opengl32\src\api_entry.d
Loading ..\opengl32\src\dll_entry.d
Loading ..\opengl32\src\forward_initialization.d
None =>
object.Exception@DustMite\dustmite.d(271): Initial test fails
----------------
0x00403B9B
0x00459407
0x00459389
0x00459224
0x00441478
0x76DE8484 in BaseThreadInitThunk
0x77E52EC0 in RtlValidSecurityDescriptor
0x77E52E90 in RtlValidSecurityDescriptor
No