Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
February 07, 2005 Is this implemented? | ||||
---|---|---|---|---|
| ||||
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 Re: Is this implemented? | ||||
---|---|---|---|---|
| ||||
Posted in reply to uframer | 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 OT: Re: Is this implemented? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | 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
|
Copyright © 1999-2021 by the D Language Foundation