[Issue 8887] static arrays passed by value in extern C/C++ functions should not compile
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Nov 8 06:35:13 PST 2014
https://issues.dlang.org/show_bug.cgi?id=8887
Dicebot <public at dicebot.lv> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P1 |P2
Severity|regression |critical
--- Comment #16 from Dicebot <public at dicebot.lv> ---
(In reply to Mike Parker from comment #14)
> (In reply to Dicebot from comment #7)
> > The fact that `ref` parameters are allowed for extern(C) functions is even
> > more bizzare than the fact that static array arguments crash programs. Need
> > to check if it works, I would have never guessed to even try it.
> >
>
> This is documented. See the section "Passing D Array Arguments to C
> Functions" at http://dlang.org/interfaceToC.html.
I don't think complementary articles can be considered part of main spec - need
to copy that definitions to `extern(C)` spec itself or at least place a direct
link there.
> If anyone wants examples of existing code that will be broken by this, see
> Derelict. DerelictODE in particular, in which the matrix and vertex types
> are typedefed on the C side as fixed-size arrays and passed as such to all
> the functions that use them. Personally, I don't see the problem with
> prototyping such C functions with ref. I hope it *doesn't* change.
I am not proposing to prohibit ref-static-arrays, it would have been too much
of a breakage indeed. But situation with plain static array arguments does
sound too error-prone and impractical too keep. Think about it that way -
because of this issue you can't just take C header and tweak it until it
compiles as D code - it can still segfault at runtime after.
I will lower importance/priority though because of mentioned workaround with
`ref` that makes it possible to preserve API safety
--
More information about the Digitalmars-d-bugs
mailing list