🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

GCC-2.2.2: cp-decl.c (grok_reference_init): no type conversion done

#1017
From: Gerald Baumgartner
Date: Sat, 03 Oct 1992 19:01
49 lines
1789 bytes
For the following two lines of input (from ARM, p. 154, bottom)

	double& rd2 = 1;
	const double& rcd2 = 1;

GCC-2.2.2 produces the error messages

	stdin:1: invalid type conversion for reference 
	stdin:2: invalid type conversion for reference 

After applying the bug fix below, we get the correct error message

	stdin:1: type mismatch in initialization of `rd2' (use `const') 

and the assembly output (for a Sparc)

	.data 
	        .align 8 
	__$tmp_0: 
	        .double 0r1 
	        .global _rcd2 
	        .align 4 
	_rcd2: 
	        .word __$tmp_0 

Here's the bug fix:

--Gerald


*** cp-decl.c~	Fri May 22 15:42:16 1992
--- cp-decl.c	Sat Oct  3 13:55:06 1992
*************** grok_reference_init()
*** 4923,4929 ****
  	      && TREE_THIS_VOLATILE (init))
  	    errstr = "cannot initialize a reference to T with a volatile T";
  	}
!       else if (TREE_CODE (TREE_TYPE (type)) == TREE_CODE (TREE_TYPE (init)))
  	{
  	  init = convert (TREE_TYPE (type), init);
  	}
--- 4923,4929 ----
  	      && TREE_THIS_VOLATILE (init))
  	    errstr = "cannot initialize a reference to T with a volatile T";
  	}
!       else if (TREE_CODE (TREE_TYPE (type)) != TREE_CODE (TREE_TYPE (init)))
  	{
  	  init = convert (TREE_TYPE (type), init);
  	}
Technical Details
Message-ID: <19841@ector.cs.purdue.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cs.purdue.edu!gb

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cs.purdue.edu!gb
From: gb@cs.purdue.edu (Gerald Baumgartner)
Subject: GCC-2.2.2: cp-decl.c (grok_reference_init): no type conversion done
Message-ID: <19841@ector.cs.purdue.edu>
Sender: gnulists@ai.mit.edu
Organization: Department of Computer Science, Purdue University
Distribution: gnu
Date: Sat, 3 Oct 1992 19:01:29 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 50