Bug 19759 – compiler crash when passing static array to function with C++ linkage

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-03-23T10:55:31Z
Last change time
2020-03-21T03:56:32Z
Keywords
C++, ice
Assigned to
No Owner
Creator
simon.vanbernem

Comments

Comment #0 by simon.vanbernem — 2019-03-23T10:55:31Z
DMD crashes, when I try to pass a static array to an extern(C++) function. The promt asked me to report this crash, so I did, but I am a bit baffled that the error message is fully aware of what went wrong and asks me to use a pointer instead. I don't exactly see how this workaround would help though, since I can't change the function signature because of name-mangling, and if I just pass a pointer to the unchanged function, the type system will of course complain. I think the only way forward right now is to switch to C-linkage, so that function-mangling doesn't happen? That would be pretty annoying, since there are other overloads in the library I am using, and so I would have to provide some wrapper for that. The minimal example reads as follows: -----------------Code---------------------- extern(C++) bool fail(float[4] col); void main(){ float[4] array = [0, 1, 2, 3]; fail(array); } -----------------Code---------------------- ----------Compiler Output------------------ dmd repro.d Error: Internal Compiler Error: unable to pass static array to extern(C++) function. Error: Use pointer instead. --- ERROR: This is a compiler bug. Please report it via https://issues.dlang.org/enter_bug.cgi with, preferably, a reduced, reproducible example and the information below. DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction. --- DMD v2.084.1 predefs DigitalMars Windows CRuntime_DigitalMars CppRuntime_DigitalMars LittleEndian D_Version2 all D_InlineAsm D_InlineAsm_X86 X86 Win32 assert D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat binary C:\Program Files\D\dmd2\windows\bin\dmd.exe version v2.084.1 config C:\Program Files\D\dmd2\windows\bin\sc.ini DFLAGS '-IC:\Program Files\D\dmd2\windows\bin\..\..\src\phobos' '-IC:\Program Files\D\dmd2\windows\bin\..\..\src\druntime\import' --- object.Error@(0): Illegal Instruction ---------------- 0x004323EB ----------Compiler Output------------------
Comment #1 by simon.vanbernem — 2019-03-23T10:56:39Z
btw, I have no idea how exactly you classify the priority and severity of an issue, so I'm sorry if I got that wrong
Comment #2 by b2.temp — 2019-03-23T11:29:50Z
ICE are always somewhat critical. But once the keyword is there "Normal" or "Major" etc doesn't matter. with ICE the fix can go in the stable branch of the compiler.
Comment #3 by greeenify — 2019-03-23T15:52:07Z
FWIW all non-controversial bug fixes should go to stable.
Comment #4 by b2.temp — 2019-03-25T11:58:00Z
This is almost the same as 16575. The fix will handle both at least. *** This issue has been marked as a duplicate of issue 16575 ***