* Go patch committed: Reject nil == nil
@ 2012-12-04 6:44 Ian Lance Taylor
0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2012-12-04 6:44 UTC (permalink / raw)
To: gcc-patches, gofrontend-dev
[-- Attachment #1: Type: text/plain, Size: 262 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 526 bytes --]
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))
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-12-04 6:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-04 6:44 Go patch committed: Reject nil == nil Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).