Bug 18828 – [-betterC] helpless error in object.d

Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2018-05-04T21:44:15Z
Last change time
2018-05-23T15:26:30Z
Assigned to
No Owner
Creator
Xavier Bigand
See also
https://issues.dlang.org/show_bug.cgi?id=18493

Attachments

IDFilenameSummaryContent-TypeSize
1692opengl32.zipsource code that produce the errorapplication/x-zip-compressed20967
1693Export.zipComplete projectapplication/x-zip-compressed68074

Comments

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
(In reply to Seb from comment #1) > You can use digger for reducing it: https://github.com/CyberShadow/Digger I think Sebastian meant to direct you to Dustmite: https://github.com/CyberShadow/DustMite
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
Comment #9 by slavo5150 — 2018-05-09T06:35:43Z
Comment #10 by github-bugzilla — 2018-05-23T15:26:30Z
Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/0bb16606a23851680c818a64e6bb69e6a8e6650e Fix Issue 18828 - [-betterC] helpless error in object.d https://github.com/dlang/druntime/commit/9ade20ccd5acf6b0ab38d75e2e554a0cbf8e1fea Merge pull request #2178 from JinShil/fix_18828 Fix Issue 18828 - [-betterC] helpless error in object.d merged-on-behalf-of: Jacob Carlborg <[email protected]>