This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: bug in gcc (GCC) 4.0.1 20050727 (Red Hat 4.0.1-5)
Mark Frazer <mark@mjfrazer.org> [05/08/02 09:32]:
> Richard Guenther <richard.guenther@gmail.com> [05/08/02 09:29]:
> > Try -fno-strict-aliasing. This may be related to PR23192.
>
> -fno-strict-aliasing does indeed make the problem go away.
changing the de-serialization function to:
double parse_double(uint &offset, vector<uint8> const &bytecode)
throw (std::invalid_argument)
{
union {
uint64 ival;
double dval;
} rtn;
rtn.ival = uint64(next_byte(offset, bytecode)) << 56;
rtn.ival |= uint64(next_byte(offset, bytecode)) << 48;
rtn.ival |= uint64(next_byte(offset, bytecode)) << 40;
rtn.ival |= uint64(next_byte(offset, bytecode)) << 32;
rtn.ival |= uint64(next_byte(offset, bytecode)) << 24;
rtn.ival |= uint64(next_byte(offset, bytecode)) << 16;
rtn.ival |= uint64(next_byte(offset, bytecode)) << 8;
rtn.ival |= uint64(next_byte(offset, bytecode));
return rtn.dval;
}
Allows for the strict-aliasing optimization to be left in. So, it seems
the bug was mine, not gcc's.
I'm off to search for other reinterpret_cast abuses in my code...
cheers
-mark
--
To Captain Bender! He's the best! ...at being a big jerk who's stupid and
his big ugly face is as dumb as a butt! - Fry