[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
Sun Nov 9 10:52:05 PST 2014


https://issues.dlang.org/show_bug.cgi?id=8887

--- Comment #18 from Steven Schveighoffer <schveiguy at yahoo.com> ---
(In reply to Dicebot from comment #16)

> 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.

If we can supersede druntime's usage of extern(C) for name mangling, I think
I'm OK with making any extern(C) function that accepts a non-ref static array
an error.

(In reply to Dicebot from comment #15)

> Are there any legit extern(C) declaration in druntime at all or everything
> needs to be updated? I'll do the PR.

I think it's for historical reasons mainly -- the original version of phobos
(before druntime) had C implementations of some things, so the compiler always
hooked with C mangling.

But I think this is a good question to ask the whole community. It could very
well be that some people call the functions from C. However, I'm fairly certain
most of the extern(C) declarations are simply for name mangling and getting
around attribute requirements where needed.

--


More information about the Digitalmars-d-bugs mailing list