[gnu.g++.bug] overloading problem

David.Detlefs@DLD.AVALON.CS.CMU.EDU (07/25/89)

I'm using g++ 1.35 on a vax.

I extracted the following file from libg++'s "compare.h":

--------------------------------------------------
// This should work but doesn't.

inline int compare(int a, int b)
{
  return a - b;
}

inline int compare(float a, float b)
{
  float x = a - b;
  return (x > 0.0 ? 1 : (x < 0.0 ? -1 : 0));
}
--------------------------------------------------

Attempting to compile this produced the error message:

In function int compare (float, float):
bug2.cc:9: conflicting types for `int compare (float, float)'

I then backed off to just declarations:

--------------------------------------------------
// This should *really* work but doesn't.

int compare(int a, int b);
int compare(float a, float b);
--------------------------------------------------

Result:

bug2b.cc:4: conflicting types for `int compare (float, float)'


-- Dave