[Bug c++/27533] wrong result after reinterpret_cast from float* to int*

2006-05-10 Thread pluto at agmk dot net
--- Comment #1 from pluto at agmk dot net 2006-05-10 14:51 --- you're violating the aliasing rules, so use -fno-strict-aliasing option. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27533

[Bug c++/27533] wrong result after reinterpret_cast from float* to int*

2006-05-10 Thread ulrich dot lauther at siemens dot com
--- Comment #2 from ulrich dot lauther at siemens dot com 2006-05-10 14:53 --- Created an attachment (id=11434) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11434action=view) Complete tiny example exposing the problem I submit this version that includes stdio.h for readability,

[Bug c++/27533] wrong result after reinterpret_cast from float* to int*

2006-05-10 Thread ulrich dot lauther at siemens dot com
--- Comment #3 from ulrich dot lauther at siemens dot com 2006-05-10 14:55 --- Created an attachment (id=11435) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11435action=view) same as before, but stdio.h expanded -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27533

[Bug c++/27533] wrong result after reinterpret_cast from float* to int*

2006-05-10 Thread reichelt at gcc dot gnu dot org
--- Comment #4 from reichelt at gcc dot gnu dot org 2006-05-10 14:59 --- As Pawel already pointed out: Your code is brokan as you are violating the aliasing rules. Please read about this in the non-bug section of http://gcc.gnu.org/bugs.html : Casting does not work as expected when

[Bug c++/27533] wrong result after reinterpret_cast from float* to int*

2006-05-10 Thread pluto at agmk dot net
--- Comment #5 from pluto at agmk dot net 2006-05-10 15:26 --- (In reply to comment #0) The code inline int almost_equal(float a, float b, int maxUlps = 16) { int intDiff = *(reinterpret_castint*(a)) - *(reinterpret_castint*(b)); if you really need such