🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

overloading problem

#293
From: David.Detlefs
Date: Mon, 24 Jul 1989 22:40
39 lines
1310 bytes
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
Technical Details
Message-ID: <8907250055.AA12967@AENEAS.MIT.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!tut.cis.ohio-state.edu!DLD.AVALON.CS.CMU.EDU!David.Detlefs

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!tut.cis.ohio-state.edu!DLD.AVALON.CS.CMU.EDU!David.Detlefs
From: David.Detlefs@DLD.AVALON.CS.CMU.EDU
Newsgroups: gnu.g++.bug
Subject: overloading problem
Message-ID: <8907250055.AA12967@AENEAS.MIT.EDU>
Date: 24 Jul 89 22:40:41 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 39