[Issue 1679] New: D should cast char[] to char* when used in a variadic argument in extern(C) context

Brad Roberts braddr at puremagic.com
Mon Nov 19 20:56:05 PST 2007


On Tue, 20 Nov 2007, d-bugmail at puremagic.com wrote:

>   When the "-c" argument is sent as the first
> argument of the variadic part, D sends a char[] and not a char*, meaning
> that it puts 2, "-c" on the stack, which confuses the C.
>   I believe that D should do the implicit cast in that case, as it'll
> break a _lot_ of programs using C APIs and variadic arguments in very
> subtle ways.

It would only potentially be safe to implicitly do this for literals.  In 
D, char[]'s don't necessairily have a null terminating byte.  Literals do.  
This implicit cast used to exist and was removed due to it being fairly 
unsafe to do in the general case.


More information about the Digitalmars-d-bugs mailing list