This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/34992] compiler produces wrong code when optimizing
- From: "roebel at ircam dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Jan 2008 00:14:33 -0000
- Subject: [Bug middle-end/34992] compiler produces wrong code when optimizing
- References: <bug-34992-12390@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #6 from roebel at ircam dot fr 2008-01-28 00:14 -------
Andrew,
while -ffloat-store fixes the problem, this solution is obviously not
acceptable. Moreover, here the problem is not that I compare floats
using <= the problem is that std::set<double>::insert(double) compares
set elements using std::less<double> which in this case just does not work.
Now using std::less<double> for a set does not seem not carefull
to me, be cause this is the default. So the default is nonsense ?
I fixed the problem by means of using std::set<double,dless>
with dless being
struct dless{
typedef double first_argument_type;
typedef double second_argument_type;
typedef bool result_type;
volatile double d1;
volatile double d2;
bool operator()(double in1, double in2) {
d1 = in1;
d2 = in2;
return d1 < d2;
}
};
which proves that the problem is in the std::less operator
and not in my code. In fact this even means that
std::less<double> and std::greater<double> and all
their company is useless because you can never be sure what they
are comparing. So many of the functions of the std::library
may fail!! Am I wrong, here ?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34992