Thread overview | |||||
---|---|---|---|---|---|
|
April 08, 2011 String literal converted to char*. Doc bug? | ||||
---|---|---|---|---|
| ||||
The documentation for array says
> (...), and a string literal can be implicitly cast to a char*
But this fails
char* a = "a"; // cannot implicitly convert expression "a" of type
string to char*
This works:
char* a = cast(char*)"a";
Is the documentation a bit out of date, is this a bug, or is it only correct in some cases?
|
April 08, 2011 Re: String literal converted to char*. Doc bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to simendsjo | simendsjo Wrote:
> The documentation for array says
> > (...), and a string literal can be implicitly cast to a char*
>
> But this fails
> char* a = "a"; // cannot implicitly convert expression "a" of type
> string to char*
>
> This works:
> char* a = cast(char*)"a";
>
> Is the documentation a bit out of date, is this a bug, or is it only correct in some cases?
I think the documentation is out of date. Untested:
const(char)* a = "a";
|
April 08, 2011 Re: String literal converted to char*. Doc bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phililps | Ok, files bug: http://d.puremagic.com/issues/show_bug.cgi?id=5820 |
Copyright © 1999-2021 by the D Language Foundation