Thread overview
Is this implemented?
Feb 07, 2005
uframer
OT: Re: Is this implemented?
Feb 07, 2005
Regan Heath
February 07, 2005
The document reads "It is an error to return the address of or a reference
to a local variable." in the section of Local Variables in function.html .
But when i use dmd 0.112 to compile this:
<code>
import std.c.stdio;

int* f()
{
 int a;
 return &a;
}

int main ( char [] [] args )
{
 int* b = f();
 getchar();
 return 1;
}
</code>

it succeeded.
Is this an unimplemented feature or i've missed something?


February 07, 2005
uframer wrote:

> The document reads "It is an error to return the address of or a reference to a local variable." in the section of Local Variables in function.html . 
[...]
> Is this an unimplemented feature or i've missed something? 

Just because you got away with it, doesn't make it legal ;-)

That spec line just gives a future compiler a license to kill.

--anders
February 07, 2005
On Mon, 07 Feb 2005 11:33:22 +0100, Anders F Björklund <afb@algonet.se> wrote:
> uframer wrote:
>
>> The document reads "It is an error to return the address of or a reference to a local variable." in the section of Local Variables in function.html .
> [...]
>> Is this an unimplemented feature or i've missed something?
>
> Just because you got away with it, doesn't make it legal ;-)
>
> That spec line just gives a future compiler a license to kill.

I like it! "DMD007 licensed to kill".

Regan