Open Quuxplusone opened 4 years ago
Bugzilla Link | PR44110 |
Status | NEW |
Importance | P enhancement |
Reported by | Ditlef Martens (ditlef.martens@gmail.com) |
Reported on | 2019-11-21 23:33:28 -0800 |
Last modified on | 2019-11-21 23:54:50 -0800 |
Version | 8.0 |
Hardware | PC Linux |
CC | blitzrakete@gmail.com, craig.topper@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
This code also fails with gcc compiled with -O3. It passes on both clang and
gcc if you add -fno-strict-aliasing to the command line. I believe the problem
lies in the reinterpret cast used to turn the float into a uint32_t.
This is a way to turn the float into a uint32_t and back that avoids the issue
inline
void swap(float & value)
{
uint32_t tmp;
memcpy(&tmp, &value, sizeof(float));
swap(tmp);
memcpy(&value, &tmp, sizeof(float));
}