February 26, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1869





------- Comment #17 from shro8822@vandals.uidaho.edu  2008-02-26 12:57 -------
(In reply to comment #12)
> (In reply to comment #11)
> 
> That is incorrect. There is no hidden pointer and no extra indirection. There is a confusion somewhere along the way, so please let me give an example:
> 

are you talking C or D? I could have sworn that in C a "pointer to a fixed size array" (e.i. double indirection) was written as "int[4]*". If it isn't, how is it written?

Oh. I think I just figured it out!:

int[4] a;
int[4]* i = &a;

i points to the same point as a but has a different type *i is the same pointer as i but with the type of a and **i is the content.

OK what I want to do is return *(&a), a type that is the same as "a" but is
mutable.

p.s. Darn I should check the by line before I post


-- 

February 26, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1869


andrei@metalanguage.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement




------- Comment #18 from andrei@metalanguage.com  2008-02-26 13:09 -------
(In reply to comment #17)
> are you talking C or D?

Both.

> I could have sworn that in C a "pointer to a fixed size
> array" (e.i. double indirection) was written as "int[4]*". If it isn't, how is
> it written?

It is written like that, and there is no double indirection.

> Oh. I think I just figured it out!:
> 
> int[4] a;
> int[4]* i = &a;
> 
> i points to the same point as a but has a different type *i is the same pointer as i but with the type of a and **i is the content.

That is correct.

> OK what I want to do is return *(&a), a type that is the same as "a" but is
> mutable.

You'd need to return a reference to a fixed-size array, which in C does not exist, in C++ is spelled int[4]&, and in D is spelled ref int[4] but so far only applies to function arguments.

Note that neither would be mutable, so you seem to want something that is physically possible but can't be expressed in either of the three languages.

I'm keeping this bug report as a request for returning arrays by value, but I guess it's duplicated with a couple others.


-- 

February 26, 2008
Reply to Janice,

> On 26/02/2008, d-bugmail@puremagic.com <d-bugmail@puremagic.com>
> wrote:
> 
>> but that still doesn't solve the base issue: I want a function to
>> return a pointer to a chunk of memory that is 4 ints in a row (or it
>> is that as best the compiler can tell).
>> 
>
> Hopefully, one of these will suit your needs
>

None of those do quite what I want (see comment #18 down at the bottom) 


November 26, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1869


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug@yahoo.com.au
         Resolution|                            |FIXED


--- Comment #20 from Don <clugdbug@yahoo.com.au> 2009-11-26 08:02:23 PST ---
Fixed DMD2.036: fixed-length arrays are now passed by value.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
1 2 3
Next ›   Last »