www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Is this implemented?

reply "uframer" <uframer sina100.com.cn> writes:
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? 
Feb 07 2005
parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
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
Feb 07 2005
parent "Regan Heath" <regan netwin.co.nz> writes:
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
Feb 07 2005