mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 09:05:31 +00:00
Drop no-strict-aliasing and fix 2 places where it was violated
This commit is contained in:
parent
07bc19b489
commit
2473c69679
5 changed files with 46 additions and 49 deletions
|
@ -35,7 +35,7 @@ Revision History:
|
|||
|
||||
parameter::~parameter() {
|
||||
if (m_kind == PARAM_RATIONAL) {
|
||||
reinterpret_cast<rational *>(m_rational)->~rational();
|
||||
m_rational.~rational();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,14 +50,14 @@ parameter& parameter::operator=(parameter const& other) {
|
|||
return *this;
|
||||
}
|
||||
if (m_kind == PARAM_RATIONAL) {
|
||||
reinterpret_cast<rational *>(m_rational)->~rational();
|
||||
m_rational.~rational();
|
||||
}
|
||||
m_kind = other.m_kind;
|
||||
switch(other.m_kind) {
|
||||
case PARAM_INT: m_int = other.get_int(); break;
|
||||
case PARAM_AST: m_ast = other.get_ast(); break;
|
||||
case PARAM_SYMBOL: new (m_symbol) symbol(other.get_symbol()); break;
|
||||
case PARAM_RATIONAL: new (m_rational) rational(other.get_rational()); break;
|
||||
case PARAM_SYMBOL: m_symbol = other.get_symbol(); break;
|
||||
case PARAM_RATIONAL: m_rational = other.get_rational(); break;
|
||||
case PARAM_DOUBLE: m_dval = other.m_dval; break;
|
||||
case PARAM_EXTERNAL: m_ext_id = other.m_ext_id; break;
|
||||
default:
|
||||
|
|
|
@ -100,12 +100,12 @@ private:
|
|||
|
||||
// It is not possible to use tag pointers, since symbols are already tagged.
|
||||
union {
|
||||
int m_int; // for PARAM_INT
|
||||
ast* m_ast; // for PARAM_AST
|
||||
char m_symbol[sizeof(symbol)]; // for PARAM_SYMBOL
|
||||
char m_rational[sizeof(rational)]; // for PARAM_RATIONAL
|
||||
double m_dval; // for PARAM_DOUBLE (remark: this is not used in float_decl_plugin)
|
||||
unsigned m_ext_id; // for PARAM_EXTERNAL
|
||||
int m_int; // for PARAM_INT
|
||||
ast* m_ast; // for PARAM_AST
|
||||
symbol m_symbol; // for PARAM_SYMBOL
|
||||
rational m_rational; // for PARAM_RATIONAL
|
||||
double m_dval; // for PARAM_DOUBLE (remark: this is not used in float_decl_plugin)
|
||||
unsigned m_ext_id; // for PARAM_EXTERNAL
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -114,12 +114,10 @@ public:
|
|||
explicit parameter(int val): m_kind(PARAM_INT), m_int(val) {}
|
||||
explicit parameter(unsigned val): m_kind(PARAM_INT), m_int(val) {}
|
||||
explicit parameter(ast * p): m_kind(PARAM_AST), m_ast(p) {}
|
||||
explicit parameter(symbol const & s): m_kind(PARAM_SYMBOL) { new (m_symbol) symbol(s); }
|
||||
explicit parameter(rational const & r): m_kind(PARAM_RATIONAL) { new (m_rational) rational(r); }
|
||||
explicit parameter(symbol const & s): m_kind(PARAM_SYMBOL), m_symbol(s) {}
|
||||
explicit parameter(rational const & r): m_kind(PARAM_RATIONAL), m_rational(r) {}
|
||||
explicit parameter(double d):m_kind(PARAM_DOUBLE), m_dval(d) {}
|
||||
explicit parameter(const char *s):m_kind(PARAM_SYMBOL) {
|
||||
new (m_symbol) symbol(s);
|
||||
}
|
||||
explicit parameter(const char *s):m_kind(PARAM_SYMBOL), m_symbol(s) {}
|
||||
explicit parameter(unsigned ext_id, bool):m_kind(PARAM_EXTERNAL), m_ext_id(ext_id) {}
|
||||
parameter(parameter const&);
|
||||
|
||||
|
@ -156,8 +154,8 @@ public:
|
|||
|
||||
int get_int() const { SASSERT(is_int()); return m_int; }
|
||||
ast * get_ast() const { SASSERT(is_ast()); return m_ast; }
|
||||
symbol const & get_symbol() const { SASSERT(is_symbol()); return *(reinterpret_cast<const symbol *>(m_symbol)); }
|
||||
rational const & get_rational() const { SASSERT(is_rational()); return *(reinterpret_cast<const rational *>(m_rational)); }
|
||||
symbol const & get_symbol() const { SASSERT(is_symbol()); return m_symbol; }
|
||||
rational const & get_rational() const { SASSERT(is_rational()); return m_rational; }
|
||||
double get_double() const { SASSERT(is_double()); return m_dval; }
|
||||
unsigned get_ext_id() const { SASSERT(is_external()); return m_ext_id; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue