[gnumeric] Expr: avoid trouble with aliasing and with valgrind.



commit 4a87da3d2d277cc4e2102106c404e2ce551edb88
Author: Morten Welinder <terra gnome org>
Date:   Sat Oct 25 19:01:15 2014 -0400

    Expr: avoid trouble with aliasing and with valgrind.
    
    Valgrind sees a guint8 as a bitfield sometimes and has problems with
    that.

 ChangeLog       |    6 ++++++
 src/expr-impl.h |    3 +--
 2 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1afc80e..59b85da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-10-25  Morten Welinder  <terra gnome org>
+
+       * src/expr-impl.h (GNM_EXPR_GET_OPER): Redefine in a way that
+       ought to survive both gcc's aliasing analysis and valgrind's
+       bitfield problems.
+
 2014-10-24  Morten Welinder  <terra gnome org>
 
        * src/xml-sax-write.c (xml_write_selection_info): Plug leak.
diff --git a/src/expr-impl.h b/src/expr-impl.h
index 57dec38..e155f13 100644
--- a/src/expr-impl.h
+++ b/src/expr-impl.h
@@ -63,7 +63,6 @@ struct _GnmExprSet {
 };
 
 union _GnmExpr {
-       guint8                  oper;
        GnmExprConstant         constant;
        GnmExprFunction         func;
        GnmExprUnary            unary;
@@ -75,7 +74,7 @@ union _GnmExpr {
        GnmExprSet              set;
 };
 
-#define GNM_EXPR_GET_OPER(e) ((GnmExprOp)((e)->oper))
+#define GNM_EXPR_GET_OPER(e_) (0 ? (e_) == (GnmExpr const *)0 : (GnmExprOp)*(guint8*)(e_))
 
 #define gnm_expr_constant_init(expr, val)      \
 do {                                           \


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]