remove options infrastructure code which depended on undefined behavior
authorKshitij Bansal <kshitij@cs.nyu.edu>
Tue, 13 Oct 2015 23:59:22 +0000 (19:59 -0400)
committerKshitij Bansal <kshitij@cs.nyu.edu>
Tue, 13 Oct 2015 23:59:22 +0000 (19:59 -0400)
appears to be source of crashes on mac

src/expr/expr_template.h
src/options/options.h
src/printer/printer.h

index d769ed109ad6cb9d441b729625e9a43beb4c4694..ae0fad8972926a049f824a18eacb8bcb1bf14476 100644 (file)
@@ -649,7 +649,7 @@ public:
     long& l = out.iword(s_iosIndex);
     if(l == 0) {
       // set the default print depth on this ostream
-      if(&Options::current() != NULL) {
+      if(not Options::isCurrentNull()) {
         l = options::defaultExprDepth();
       }
       if(l == 0) {
@@ -801,7 +801,7 @@ public:
     if(l == 0) {
       // set the default dag setting on this ostream
       // (offset by one to detect whether default has been set yet)
-      if(&Options::current() != NULL) {
+      if(not Options::isCurrentNull()) {
         l = options::defaultDagThresh() + 1;
       }
       if(l == 0) {
@@ -884,7 +884,7 @@ public:
     if(l == 0) {
       // set the default language on this ostream
       // (offset by one to detect whether default has been set yet)
-      if(&Options::current() != NULL) {
+      if(not Options::isCurrentNull()) {
         l = options::outputLanguage() + 1;
       }
       if(l <= 0 || l > language::output::LANG_MAX) {
index 092fbe50716c19460a55b267510fd1c2df705989..9656007f4a07eaf150f5b6a27ad7d300202c2646 100644 (file)
@@ -60,6 +60,11 @@ class CVC4_PUBLIC Options {
 
 public:
 
+  /** Return true if current Options are null */
+  static inline bool isCurrentNull() {
+    return s_current == NULL;
+  }
+
   /** Get the current Options in effect */
   static inline Options& current() {
     return *s_current;
index fcc0df93c1497605767c3ffe54c88a03284bf264..44e5ac9f41e26b52ac4e0d21de1016a4f219587b 100644 (file)
@@ -62,7 +62,7 @@ public:
       //
       // Options can be null in certain circumstances (e.g., when printing
       // the singleton "null" expr.  So we guard against segfault
-      if(&Options::current() != NULL) {
+      if(not Options::isCurrentNull()) {
         if(options::outputLanguage.wasSetByUser()) {
           lang = options::outputLanguage();
         }