public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Go patch committed: Fix bug comparing struct/array to interface
@ 2014-08-29  3:06 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2014-08-29  3:06 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 600 bytes --]

The Go frontend had a bug comparing a struct or array value to an
interface value when the struct or array was not addressable.  The code
that was supposed to force the struct/array into a temporary variable
did not fire, because the compiler erroneously tried to handle it as a
straight struct/array comparison.  This patch fixes the problem.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline and 4.9 branch.

The test case has been committed to the master testsuite; see
https://codereview.appspot.com/135170043 .  This fixes
http://golang.org/issue/8612 .

Ian


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 890 bytes --]

diff -r 3a08729cc5f8 go/expressions.cc
--- a/go/expressions.cc	Tue Aug 26 21:09:25 2014 -0700
+++ b/go/expressions.cc	Thu Aug 28 19:39:45 2014 -0700
@@ -5187,10 +5187,13 @@
   // Lower struct, array, and some interface comparisons.
   if (op == OPERATOR_EQEQ || op == OPERATOR_NOTEQ)
     {
-      if (left->type()->struct_type() != NULL)
+      if (left->type()->struct_type() != NULL
+	  && right->type()->struct_type() != NULL)
 	return this->lower_struct_comparison(gogo, inserter);
       else if (left->type()->array_type() != NULL
-	       && !left->type()->is_slice_type())
+	       && !left->type()->is_slice_type()
+	       && right->type()->array_type() != NULL
+	       && !right->type()->is_slice_type())
 	return this->lower_array_comparison(gogo, inserter);
       else if ((left->type()->interface_type() != NULL
                 && right->type()->interface_type() == NULL)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-08-29  3:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-29  3:06 Go patch committed: Fix bug comparing struct/array to interface 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).