This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: Don't crash if a named constant has no type
- 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: Tue, 04 Jan 2011 12:18:35 -0800
- Subject: Go patch committed: Don't crash if a named constant has no type
When compiling invalid code it's possible for the type to never be set
for a named constant. All the cases which care check for NULL except
one. This patch fixes the final case. Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu. Committed to mainline.
Ian
diff -r 6f834ce27f8b go/expressions.cc
--- a/go/expressions.cc Tue Jan 04 11:45:52 2011 -0800
+++ b/go/expressions.cc Tue Jan 04 12:15:47 2011 -0800
@@ -2680,7 +2680,8 @@
// object is an abstract int or float, we try to get the abstract
// value. Otherwise we may lose something in the conversion.
if (this->type_ != NULL
- && this->constant_->const_value()->type()->is_abstract())
+ && (this->constant_->const_value()->type() == NULL
+ || this->constant_->const_value()->type()->is_abstract()))
{
Expression* expr = this->constant_->const_value()->expr();
mpz_t ival;