digitalmars.D - What's going on here?
- Manu (16/16) Jan 09 2014 So I'm interacting with C (although it works the same in D), I call a
- Andrei Alexandrescu (5/21) Jan 09 2014 It's a bug in the compiler. Evaluation should proceed as if it were
- Manu (2/30) Jan 09 2014
- monarch_dodra (6/10) Jan 09 2014 I remember this conversation popping up repeatedly. *Did* we ever
- Jonathan M Davis (6/19) Jan 11 2014 Walter has stated that he wanted to, but AFAIK, it never actually became...
- Jakob Ovrum (4/12) Jan 11 2014 It is in the spec[1].
So I'm interacting with C (although it works the same in D), I call a function that returns a pointer, and gives the size through an out arg: ubyte* test(size_t* ptr) { *ptr = 100; return cast(ubyte*)1234; } And call it, but immediately use the size argument to slice a range: size_t size; ubyte[] t = test(&size)[0..size]; t is null. If I do this, it works: size_t size; ubyte* pt = test(&size); ubyte[] t = pt[0..size]; Why should I need that extra line?
Jan 09 2014
On 1/9/14 9:08 PM, Manu wrote:So I'm interacting with C (although it works the same in D), I call a function that returns a pointer, and gives the size through an out arg: ubyte* test(size_t* ptr) { *ptr = 100; return cast(ubyte*)1234; } And call it, but immediately use the size argument to slice a range: size_t size; ubyte[] t = test(&size)[0..size]; t is null. If I do this, it works: size_t size; ubyte* pt = test(&size); ubyte[] t = pt[0..size]; Why should I need that extra line?It's a bug in the compiler. Evaluation should proceed as if it were strictly left to right. So test(&size) must be called before size is loaded to construct the slice. Please report. Andrei
Jan 09 2014
Reported. On 10 January 2014 15:34, Andrei Alexandrescu <SeeWebsiteForEmail erdani.orgwrote:On 1/9/14 9:08 PM, Manu wrote:So I'm interacting with C (although it works the same in D), I call a function that returns a pointer, and gives the size through an out arg: ubyte* test(size_t* ptr) { *ptr = 100; return cast(ubyte*)1234; } And call it, but immediately use the size argument to slice a range: size_t size; ubyte[] t = test(&size)[0..size]; t is null. If I do this, it works: size_t size; ubyte* pt = test(&size); ubyte[] t = pt[0..size]; Why should I need that extra line?It's a bug in the compiler. Evaluation should proceed as if it were strictly left to right. So test(&size) must be called before size is loaded to construct the slice. Please report. Andrei
Jan 09 2014
On Friday, 10 January 2014 at 05:34:27 UTC, Andrei Alexandrescu wrote:It's a bug in the compiler. Evaluation should proceed as if it were strictly left to right. So test(&size) must be called before size is loaded to construct the slice. Please report. AndreiI remember this conversation popping up repeatedly. *Did* we ever make the choice to enforce this? I mean, is this part of the spec now? When did it happen? I seem to remember Walter was always against it.
Jan 09 2014
On Friday, January 10, 2014 07:24:43 monarch_dodra wrote:On Friday, 10 January 2014 at 05:34:27 UTC, Andrei Alexandrescu wrote:Walter has stated that he wanted to, but AFAIK, it never actually became official. But knowing how things tend to go around here, even if Walter, Andrei, and all of the main devs thought that it was official, it still probably wouldn't be in the spec. - Jonathan M DavisIt's a bug in the compiler. Evaluation should proceed as if it were strictly left to right. So test(&size) must be called before size is loaded to construct the slice. Please report. AndreiI remember this conversation popping up repeatedly. *Did* we ever make the choice to enforce this? I mean, is this part of the spec now? When did it happen? I seem to remember Walter was always against it.
Jan 11 2014
On Saturday, 11 January 2014 at 11:03:22 UTC, Jonathan M Davis wrote:Walter has stated that he wanted to, but AFAIK, it never actually became official. But knowing how things tend to go around here, even if Walter, Andrei, and all of the main devs thought that it was official, it still probably wouldn't be in the spec. - Jonathan M DavisIt is in the spec[1]. [1] http://dlang.org/expression.html
Jan 11 2014