🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1621

g++ 1.27 does not generate warning

#1621
From: Tom Vijlbrief
Date: Wed, 18 Jan 1989 13:00
64 lines
1610 bytes
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
===============================================================================
Technical Details
Message-ID: <432@tnosoes.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!mcdchg!rutgers!labrea!eos!ames!xanth!uunet!mcvax!hp4nl!tnosoes!tom

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!mcdchg!rutgers!labrea!eos!ames!xanth!uunet!mcvax!hp4nl!tnosoes!tom
From: tom@tnosoes.UUCP (Tom Vijlbrief)
Newsgroups: gnu.g++.bug
Subject: g++ 1.27 does not generate warning
Keywords: c++, g++ 1.27
Message-ID: <432@tnosoes.UUCP>
Date: 18 Jan 89 13:00:21 GMT
Organization: TNO Institute for Perception, Soesterberg, The Netherlands
Lines: 64