Commit 55f39e2a01d0940f88401a5f471c0cb912ceecc6

Martin Mitas 2016-10-11T11:13:16

Fix #definition of MD_ASSERT and MD_UNREACHABLE for non-debug gcc builds.

diff --git a/md4c/md4c.c b/md4c/md4c.c
index fad5610..3631d0b 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -176,18 +176,21 @@ md_log(MD_CTX* ctx, const char* fmt, ...)
                     exit(1);                                            \
                 }                                                       \
             } while(0)
+
+    #define MD_UNREACHABLE()        MD_ASSERT(1 == 0)
 #else
-    #ifdef __gnuc__
-        #define MD_ASSERT(cond)     do { __builtin_expect((condition) != 0, !0); } while(0)
+    #ifdef __GNUC__
+        #define MD_ASSERT(cond)     do { if(!(cond)) __builtin_unreachable(); } while(0)
+        #define MD_UNREACHABLE()    do { __builtin_unreachable(); } while(0)
     #elif defined _MSC_VER  &&  _MSC_VER > 120
         #define MD_ASSERT(cond)     do { __assume(cond); } while(0)
+        #define MD_UNREACHABLE()    do { __assume(0); } while(0)
     #else
         #define MD_ASSERT(cond)     do {} while(0)
+        #define MD_UNREACHABLE()    do {} while(0)
     #endif
 #endif
 
-#define MD_UNREACHABLE()            MD_ASSERT(1 == 0)
-
 
 /*****************
  ***  Helpers  ***