From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: strange warning Date: Sat, 14 Dec 1996 19:49:18 -0800 Organization: Alcyone Systems Lines: 25 Message-ID: <32B3753E.26758647@alcyone.com> References: <58vhpj$ors AT nntp DOT novia DOT net> NNTP-Posting-Host: newton.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Alaric Dailey wrote: > I am trying to create a make file for a package of source code written in > ansi-C everything seems to compile ok except for one code fragment. see > below. this code always produces this warning > > context.c: In function `go_deep': > context.c:34 warning: function returns address of local variable This is inherently a bad thing. Perhaps the authors are trying to do something tricky based on the knowledge that in the limited circumstances this is to be used everything will be okay, but that seems unlikely in a preemptive multitasking system. Basically, the problem is that an automatic variable is destroyed once the block it is declared in is left. Returning the address of an automatic variable is a Bad Thing To Do -- it means that you're pointing to an area of the stack which may be reclaimed at any time. -- Erik Max Francis | max AT alcyone DOT com Alcyone Systems | http://www.alcyone.com/max/ San Jose, California | 37 20 07 N 121 53 38 W &tSftDotIotE | R^4: the 4th R is respect "You must surely know if man made heaven | Then man made hell"