[Issue 16772] ICE when using extern(C++) and ubyte[] return value

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Nov 28 10:28:58 PST 2016


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

--- Comment #3 from Sprink <sprink.noreply at gmail.com> ---
(In reply to Atila Neves from comment #2)
> I should have myself a bit clearer: I don't expect to be able to call a
> function that returns `ubyte[]` from C++. I expect the compiler to not crash
> and tell me what it is I did that was wrong. What happened to me is I had
> `extern(C++):` in a file that ended with only functions supposed to be
> called from C++. Then I added another function at the end and got the ICE.
> 
> Notice as well that there is no file or line information in the error
> message. I'd made several changes at once and had to figure out exactly
> where this error was coming from (how is ubyte[] not supported??).
> 
> Also, `extern(C)` doesn't crash the compiler. Or generate an error, and I'm
> not sure which is worse.

I see what you mean now, yah it should definitely be more informative.

For the extern(C) part, it shouldn't be an error, extern(C) is just a
convention. It has no type information in the mangled name, so ubyte[] won't
have to be mangled to match something that C doesn't have. If you have a
function with extern(C) used, then D calls a function like GetProcAddress, it
can then cast it to proper function type with ubyte[] and use it fine. So I
don't really see why it should be an error.

--


More information about the Digitalmars-d-bugs mailing list