Advertisement

[PATCH] curly braces around some asserts

Started by January 20, 2014 03:24 AM
1 comment, last by iraxef 10 years, 10 months ago

The attached/proposed patch addresses a handful of if's/else's which are immediately followed by an asASSERT(), without any curly braces. In case the underlying assert is compiled out entirely, this can lead to unintended consequences.

For example:


Index: as_symboltable.h
===================================================================
--- as_symboltable.h	(revision 1811)
+++ as_symboltable.h	(working copy)
@@ -380,7 +380,9 @@
 			m_map.Erase(cursor);
 	}
 	else
+    {
 		asASSERT(false);
+    }

This shouldn't be a problem. if asASSERT() is defined to blank, the resulting code after preprocessing is:

 
@@ -380,7 +380,9 @@
            m_map.Erase(cursor);
    }
    else
        ;

The ; ends the else, so there is no unintended consequence.

Advertisement

Fair enough. I prefer being more explicit, but thanks for the clarification.

This topic is closed to new replies.

Advertisement