🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

bug in g++

#142
From: Gjermund S|rseth
Date: Thu, 23 Jul 1992 00:03
40 lines
1881 bytes
The following file:
/////////////////////////////////////////////////
int strlen(const char *t);

class X {
  char *text;
public:
  X(const X &v) { text = v.text; }

// The error is caused by this function declaration.
  X & xyz() { return *this; }

  operator int() { return strlen(t); }
};
//////////////////////////////////////////////////
Causes version 2.1 of gcc/g++ to enter a loop giving reeatedly the
following error message:

in conversion to type `X'
bad argument 0 for function `X::X (const class X&)' (type was int )

First of all I can't see why it should convert to type 'X' at all, since
this should be of type (X *) the expression *this is already of type 'X',
Secondly it obviously converts the *this to an int, due to the
'operation int()' declaration further below. I can't see why it should
first convert to int using this conversion operator and then in the next
moment complain that it has an argument of wrong type (int instead of X).

I may have got all this wrong, but in either case the compiler shouldn't
enter a loop with control-C as one of the few possibilities for escape.

Alf

PS: as I'm writing this bug report; is it possible to ask where one can
get info about further plans for g++: Will exception as in C++ 3.0 be
implemented (g++'s exception mechanism is not following the standard as
far as I can see), are there any plans for implementing templates?


E-mail: alfs@ifi.uio.no
Technical Details
Message-ID: <199207222003.AAyrsa.ifi.uio.no07666@yrsa.ifi.uio.no>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ifi.uio.no!gjermuns

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ifi.uio.no!gjermuns
From: gjermuns@ifi.uio.no (Gjermund S|rseth)
Newsgroups: gnu.g++.bug
Subject: bug in g++
Message-ID: <199207222003.AAyrsa.ifi.uio.no07666@yrsa.ifi.uio.no>
Date: 23 Jul 92 00:03:35 GMT
Sender: gnulists@ai.mit.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 40
Approved: bug-g++@prep.ai.mit.edu