Error: functions cannot return static array float[4u][4u]

Jason House jason.james.house at gmail.com
Thu Feb 21 15:22:47 PST 2008


Jason House wrote:

> Spacen Jasset wrote:
> 
>> For this member function:
>> 
>> float[4][4] toFloatArray4x4()
>> {
>> float f[4][4];
>> return f;
>> }
> 
> This looks like doing the following in C++:
> C toC(){
>   C c;
>   return c;
> }
> 
> Which is an error (regardless of what the compiler says).  c is allocated
> on
> the heap and is deallocated when the function exits.  It may be that the
> same effect is happening here.  I'm sure this kind of thing could get
> fixed in a similar way to how full closures were fixed...

I don't know why I said heap instead of stack, but I should have said stack.


More information about the Digitalmars-d-learn mailing list