tom@tnosoes.UUCP (Tom Vijlbrief) (01/18/89)
G++ 1.27 does generate a warning when a reference to a local automatic variable is returned, but NOT when a reference to an expression is returned. int &test1() { int a= 3; return a; // Warning produced } int &test2() { return 3; // No warning produced !!! } =================================================== The generated code is identical for both functions: =================================================== #NO_APP .text .even .globl _test1 _test1: link a6,#-4 movel d2,sp@- moveq #3,d1 movel d1,a6@(-4) movel a6,d2 subql #4,d2 movel d2,d0 jra L1 L1: movel a6@(-8),d2 unlk a6 rts .even .globl _test2 _test2: link a6,#-4 movel d2,sp@- moveq #3,d1 movel d1,a6@(-4) movel a6,d2 subql #4,d2 movel d2,d0 jra L2 L2: movel a6@(-8),d2 unlk a6 rts =================================== =============================================================================== Tom Vijlbrief TNO Institute for Perception P.O. Box 23 Phone: +31 34 63 62 77 3769 ZG Soesterberg E-mail: tnosoes!tom@mcvax.cwi.nl The Netherlands or: uunet!mcvax!tnosoes!tom ===============================================================================