Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!DLD.AVALON.CS.CMU.EDU!David.Detlefs From: David.Detlefs@DLD.AVALON.CS.CMU.EDU Newsgroups: gnu.g++.lib.bug Subject: compare.h bug Message-ID: <8907241934.AA12368@AENEAS.MIT.EDU> Date: 24 Jul 89 19:33:25 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 50 Two bugs actually -- Using g++: 1.35 libg++: 1.35.1 First, I attempted to compile include.c, which only includes compare.h, and got many errors of the form In function int compare (short int, short int): include.c:7: conflicting types for `int compare (short int, short int)' These were fixed when I put an "overload compare;" at the top. I guess this is really a g++ error, and I'll report it there -- but I want to know if my understanding that libg++-1.x should compile with g++-1.x is wrong. Second, and more serious: compare.h includes the definitions -------------------------------------------------- inline int compare(float a, float b) { return a - b; } inline int compare(double a, double b) { return a - b; } -------------------------------------------------- These cause warnings when compiled, and it's a good thing: they're just wrong. For example, compare(0.5, 0.0); returns 0 instead of a number > 0. -------------------------------------------------- inline int compare(float a, float b) { float x = a - b; return (x > 0.0 ? 1 : (x < 0.0 ? -1 : 0)); } inline int compare(double a, double b) { double x = a - b; return (x > 0.0 ? 1 : (x < 0.0 ? -1 : 0)); } -------------------------------------------------- Dave