Thread View: gnu.g++.lib.bug
1 messages
1 total messages
Started by David.Detlefs
Mon, 24 Jul 1989 19:33
compare.h bug
Author: David.Detlefs
Date: Mon, 24 Jul 1989 19:33
Date: Mon, 24 Jul 1989 19:33
50 lines
1693 bytes
1693 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads