This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: Avoid reading bogus field
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Thu, 27 Mar 2014 22:20:54 -0700
- Subject: Go patch committed: Avoid reading bogus field
- Authentication-results: sourceware.org; auth=none
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.