This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

error casting an unsigned long to a double with egcs 1.0.1



Hi,

I'm working on a very large project.  There are a couple places in our code
where we are casting unsigned longs to doubles.  In some of these cases, the
casted answer is complete garbage.  When I've made a minimal test program to 
show the bug, the code works fine.  When I make a separate function to do the
work, the code works fine.  I've only been able to reproduce this bug when it's
embeded in a alot of other code.  This said, I haven't been able to pair it down
enough to demonstrate the problem with anything approaching reasonable example
length.  I'm using egcs-1.0.1.  I've been able to work around this problem
by doing as much mathematical manipulation of the unsigned long as an unsigned
long so that I can guarentee that the value is within the range of an int.  Once
this is done, I've been casting through int to the double like this:

double_variable = (double)(int)unsigned_long_variable;

I'm sorry I don't workable example of the problem.  If someone specifically
wants to see the code (its ORACLE PROC precompiled C++), I can probably get it
to you, but you would need a *ton* of other files and commercial libraries to
build it (which is why I was trying to build a smaller example of the problem
that didn't use all this junk).

Daniel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]