From: psu@cs.duke.edu (Peter Su)
Subject: g++ 2.1 goes into an infinite loop
Organization: Duke University Computer Science Dept.; Durham, N.C.
Distribution: gnu
Date: Thu, 9 Apr 1992 18:56:24 GMT

When I compile the following header file, the compiler goes into a
loop printing the following message:

point.h:22: in conversion to type `Point'
point.h:22: too many arguments for constructor `Point'

I'm using g++ v2.1 on a Sparc 2, SunOS 4.1.  I think this code used to
compile under 1.37/38/39...but it isn't mine.

Pete

// The Point class supports lexicographic comparisons between
// points, CCW and InCircle tests, etc.

#ifndef POINT_H
#define POINT_H 

#include <stream.h>
#include <math.h>

// CONVENIENCE AND DEBUGGING FUNCTIONS

typedef int boolean;

#define true 1
#define false 0

#define CR "\n"
#define SELF (*this)  	       // a more readable version of "*this".

#define DEBUG
#ifdef DEBUG
#define Assert(test, warning)   if (!(test)) cout << warning << CR
// display warning if test fails
#else
#define Assert
#endif

#define dout if (debug_output) cout
extern int debug_output;
// useful for optionally displayed debugging messages.  dout can be used
// just as cout is, but will only output if debug_output is true.

#define show(variable)  dout << #variable " = " << variable << CR
// display a variable's name and value

inline int round(float x) {return (int)floor(x+.5);}  
inline int pow(int x, int n) {return (int)round(pow((double)x, (double)n));}
inline int log(int b,int f) {return (int)round(log((double)f)/log((double)b));}

inline double distance(double x1, double y1, double x2, double y2)
   {double dx=x2-x1, dy = y2-y1; return sqrt(dx*dx+dy*dy);}

extern class Point NullPoint;  // null point at "infinity"

class Point {

 public:
  double x, y;                 // the coordinates of the point

// CONSTRUCTORS
  Point(double anx, double ay)  {x = anx; y=ay;}  
  Point(void) 	      		{x = NullPoint.x; y = NullPoint.x;}
  
// LEXICOGRAPHIC COMPARISONS BETWEEN POINTS
  boolean operator == (const Point& b) const    { return (x==b.x) && (y==b.y);}
/*  boolean operator != (const Point& b) const    { return !(b == *this);}*/
  boolean operator <  (const Point& b) const    { return (x < b.x) || 
						    ((x==b.x) && (y < b.y));}
  boolean Lowerthan (const Point& b) const      { return (y<b.y) ||
						    ((y==b.y) && x<b.x);}
  boolean operator <= (const Point& b) const    { return (*this<b) ||(*this==b);}
  boolean operator >= (const Point& b) const    { return !(*this< b);}
  boolean operator >  (const Point& b) const    { return !(*this <= b);}

  friend int Compare(Point *p1, Point *p2)
    //  Returns 1 if point p1 occurs lexicographically before point p2 
    //  0 if the points are the same, and -1 otherwise 
    {
      float result = (p1->x - p2->x);
      return result ? sign(result) : sign(p1->y - p2->y);
    }

  friend int VCompare(Point *p1, Point *p2)
    // compare points based on y-coordinates
    {
      float result = (p1->y - p2->y);
      return result ? sign(result) : sign(p1->x - p2->x);
    }

// OTHER RELATIONSHIPS
  friend boolean CCW(const Point &a, const Point& b, const Point& c) 
    {
      return
	a.x*b.y + a.y*c.x + b.x*c.y >
	b.y*c.x + a.x*c.y + b.y*c.x;
    }
  
  boolean Point::IsLeftOf(const Point& a, const Point& b) const
  // Determine if p lies to the left of the line directed from a through b. 
    {return ((x - a.x) * (b.y - a.y) < (y - a.y) * (b.x - a.x));}

  boolean Point::IsRightOf(const Point& a, const Point& b) const
 // Determine if p lies to the right of the line directed from a through b
    {   return ((x - a.x) * (b.y - a.y) > (y - a.y) * (b.x - a.x));}

  boolean IsOn(const Point& a, const Point& b) const
 // Determine if the point lies on the line directed from a through b. 
    {return (a.x-x)*(b.y-y) == (b.x-x)*(a.y-y);}


  friend boolean InCircle(Point& a, Point& b, Point& c, Point& d);
  // Determines if point d is in the circle formed by points a, b, and c.
  // See Guibas & Stolfi, p. 107. They give a 4x4 determinant 
  // to figure out if this is the case. 

  operator int() const
    {return *this != NullPoint;}
  // return 0 iff the point is not initialized   


// OUTPUT FUNCTIONS
  void Draw();

  friend ostream& operator << (ostream &o, const Point& p) 
    { return p ?  o << "(" << p.x << "," << p.y << ")" :
                  o << "(NullPoint)";}
};

extern void FindRange(Point points[], int numpoints,
	       double &minx, double &maxx, double &miny, double &maxy);
// find the minimum and maximum x and y coordinates in the given
// array.

#endif








-- 
Department of Computer Science, Duke University, Durham, NC 27706
Internet:	psu@cs.duke.edu
UUCP:		mcnc!duke!psu

Newsgroups: gnu.g++.bug