On Mon, 25 Apr 2011 12:47:20 -0400, Daniel Gibson <[email protected]> wrote:

Am 25.04.2011 17:36, schrieb Steven Schveighoffer:
On Mon, 25 Apr 2011 11:26:57 -0400, Vladimir Panteleev
<[email protected]> wrote:

On Mon, 25 Apr 2011 18:21:16 +0300, Robert Clipsham
<[email protected]> wrote:

On 25/04/2011 15:56, Vladimir Panteleev wrote:
On Mon, 25 Apr 2011 17:19:12 +0300, Steven Schveighoffer
<[email protected]> wrote:

The problem the OP has is he is casting buffer to a char *. He should
just use buffer.ptr.

Casting a string to char* is exactly the same as using the .ptr
property, as far as generated code is concerned.

Not when a string is defined internally as struct { size_t length;
immutable(char)* ptr; }. Casting to char* is a pointer to the start
of the length, not the pointer.

Try it.


I thought that "feature" was removed from D2?  Just tested it, and it's
definitely not removed yet.  But it will be :)

-Steve

I don't think it's a good idea to remove it - that would probably
(silently) break a lot of code.
As I see it there are two possibilities to remove it:
1. completely forbid casting an array to a pointer (even to get the
address of the struct) - I don't think this is desirable?

The address of the struct is &arr. There is no conflict here, and I believe this is the solution that will be implemented.

I thought the compiler disabled this "feature" a while ago, I know that Don went through and removed all the casts that were in the runtime.

-Steve

Reply via email to