3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-18 01:02:15 +00:00

fix a few compilation warnings

- remove unused variables and class fields
 - add support for gcc 4.5 & clang's __builtin_unreachable
 - fix 2 bugs related to strict aliasing
 - remove a few unused function parameters

Signed-off-by: Nuno Lopes <t-nclaud@microsoft.com>
This commit is contained in:
Nuno Lopes 2013-04-21 14:36:39 -07:00
parent 0673f645c9
commit 7ce88d4da9
46 changed files with 97 additions and 122 deletions

View file

@ -19,6 +19,7 @@ Revision History:
#include"bit_util.h"
#include"util.h"
#include"debug.h"
#include <cstring>
/**
\brief (Debugging version) Return the position of the most significant (set) bit of a
@ -67,7 +68,11 @@ unsigned msb_pos(unsigned v) {
*/
unsigned nlz_core(unsigned x) {
SASSERT(x != 0);
#ifdef __GNUC__
return __builtin_clz(x);
#else
return 31 - msb_pos(x);
#endif
}
/**
@ -92,8 +97,15 @@ unsigned nlz(unsigned sz, unsigned const * data) {
*/
unsigned ntz_core(unsigned x) {
SASSERT(x != 0);
#ifdef __GNUC__
return __builtin_ctz(x);
#else
float f = static_cast<float>(x & static_cast<unsigned>(-static_cast<int>(x)));
return (*reinterpret_cast<unsigned *>(&f) >> 23) - 0x7f;
unsigned u;
SASSERT(sizeof(u) == sizeof(f));
memcpy(&u, &f, sizeof(u));
return (u >> 23) - 0x7f;
#endif
}
/**