This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: Reject nil == nil
- 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: Mon, 03 Dec 2012 22:44:23 -0800
- Subject: Go patch committed: Reject nil == nil
This patch to the Go frontend rejects invalid comparisons in Go of nil
with nil. These comparisons have no type and no particular meaning, and
they are not permitted. Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu. Committed to mainline.
Ian
diff -r 4d8871577da5 go/expressions.cc
--- a/go/expressions.cc Mon Dec 03 22:22:34 2012 -0800
+++ b/go/expressions.cc Mon Dec 03 22:38:58 2012 -0800
@@ -5610,6 +5610,11 @@
|| this->op_ == OPERATOR_GT
|| this->op_ == OPERATOR_GE)
{
+ if (left_type->is_nil_type() && right_type->is_nil_type())
+ {
+ this->report_error(_("invalid comparison of nil with nil"));
+ return;
+ }
if (!Type::are_assignable(left_type, right_type, NULL)
&& !Type::are_assignable(right_type, left_type, NULL))
{