summaryrefslogtreecommitdiff
path: root/src/expr/expr_template.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/expr/expr_template.cpp')
-rw-r--r--src/expr/expr_template.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/expr/expr_template.cpp b/src/expr/expr_template.cpp
index f6d346630..51a734757 100644
--- a/src/expr/expr_template.cpp
+++ b/src/expr/expr_template.cpp
@@ -5,7 +5,7 @@
** Major contributors: mdeters
** Minor contributors (to current version): taking, cconway
** This file is part of the CVC4 prototype.
- ** Copyright (c) 2009, 2010 The Analysis of Computer Systems Group (ACSys)
+ ** Copyright (c) 2009, 2010, 2011 The Analysis of Computer Systems Group (ACSys)
** Courant Institute of Mathematical Sciences
** New York University
** See the file COPYING in the top-level source directory for licensing
@@ -117,10 +117,24 @@ Expr& Expr::operator=(const Expr& e) {
Assert(d_node != NULL, "Unexpected NULL expression pointer!");
Assert(e.d_node != NULL, "Unexpected NULL expression pointer!");
- ExprManagerScope ems(*this);
- *d_node = *e.d_node;
- d_exprManager = e.d_exprManager;
+ if(this != &e) {
+ if(d_exprManager == e.d_exprManager) {
+ ExprManagerScope ems(*this);
+ *d_node = *e.d_node;
+ } else {
+ // This happens more than you think---every time you set to or
+ // from the null Expr. It's tricky because each node manager
+ // must be in play at the right time.
+
+ ExprManagerScope ems1(*this);
+ *d_node = Node::null();
+ ExprManagerScope ems2(e);
+ *d_node = *e.d_node;
+
+ d_exprManager = e.d_exprManager;
+ }
+ }
return *this;
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback