This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Go patch committed: Avoid reading bogus field


PR 59545 points out that there is a case where the Go frontend reads an
invalid value from a class field.  This happens because of an incorrect
static_cast.  This patch fixes the problem to only use the static_cast
when it is valid.  Bootstrapped and ran Go tests on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r 55fb8756d889 go/expressions.cc
--- a/go/expressions.cc	Thu Mar 27 14:22:49 2014 -0700
+++ b/go/expressions.cc	Thu Mar 27 22:11:25 2014 -0700
@@ -4163,8 +4163,12 @@
 
           go_assert(!this->expr_->is_composite_literal()
                     || this->expr_->is_immutable());
-          Unary_expression* ue = static_cast<Unary_expression*>(this->expr_);
-          go_assert(ue == NULL || ue->op() != OPERATOR_AND);
+	  if (this->expr_->classification() == EXPRESSION_UNARY)
+	    {
+	      Unary_expression* ue =
+		static_cast<Unary_expression*>(this->expr_);
+	      go_assert(ue->op() != OPERATOR_AND);
+	    }
 	}
 
       // Build a decl for a constant constructor.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]