]> mj.ucw.cz Git - libucw.git/commitdiff
Added a work-around for nasty GCC bug.
authorMartin Mares <mj@ucw.cz>
Thu, 30 Aug 2007 09:48:57 +0000 (11:48 +0200)
committerMartin Mares <mj@ucw.cz>
Thu, 30 Aug 2007 09:48:57 +0000 (11:48 +0200)
lib/sorter/s-multiway.h

index fef2a3f8d1c44123080b1ac3fdda6661cc0718f2..c22af45e65524bdc8e43a8cc04c03e31731d2e24 100644 (file)
@@ -37,7 +37,15 @@ static inline void P(update_tree)(P(key) *keys, P(mwt_node) *tree, uns i)
        * the tree is the same, the actual key value can differ.
        */
     }
-  ASSERT(tree[1].i < 16);
+#if defined(__GNUC__) && (__GNUC__ * 1000 + __GNUC_MINOR__ < 4002)
+  /*
+   * This function sometimes triggers optimizer bugs in GCC 4.1.1 and
+   * possibly also earlier versions, leading to an assumption that tree[1]
+   * does not change during this function. We add an explicit memory barrier
+   * as a work-around. Ugh.
+   */
+  asm volatile ("" : : : "memory");
+#endif
 }
 
 static inline void P(set_tree)(P(key) *keys, P(mwt_node) *tree, uns i, int val)