public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Go patch committed: Fix unsafe.Sizeof for named structs
@ 2012-06-07  5:59 Ian Lance Taylor
  2012-06-07  6:23 ` Jakub Jelinek
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2012-06-07  5:59 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

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

This patch to the Go frontend fixes an embarrassing and serious bug in
which unsafe.Sizeof returns the wrong value for a named struct that
has fields that are themselves named structs.  Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu.  Committed to mainline and 4.7
branch.

Ian


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

diff -r 6db81fd6c2f2 go/types.cc
--- a/go/types.cc	Wed Jun 06 17:53:15 2012 -0700
+++ b/go/types.cc	Wed Jun 06 22:47:24 2012 -0700
@@ -7863,6 +7863,10 @@
 bool
 Named_type::do_verify()
 {
+  if (this->is_verified_)
+    return true;
+  this->is_verified_ = true;
+
   Find_type_use find(this);
   Type::traverse(this->type_, &find);
   if (find.found())
@@ -7973,6 +7977,11 @@
 
   this->create_placeholder(gogo);
 
+  // If we are called to turn unsafe.Sizeof into a constant, we may
+  // not have verified the type yet.  We have to make sure it is
+  // verified, since that sets the list of dependencies.
+  this->verify();
+
   // Convert all the dependencies.  If they refer indirectly back to
   // this type, they will pick up the intermediate tree we just
   // created.
diff -r 6db81fd6c2f2 go/types.h
--- a/go/types.h	Wed Jun 06 17:53:15 2012 -0700
+++ b/go/types.h	Wed Jun 06 22:47:24 2012 -0700
@@ -2628,8 +2628,9 @@
       interface_method_tables_(NULL), pointer_interface_method_tables_(NULL),
       location_(location), named_btype_(NULL), dependencies_(),
       is_visible_(true), is_error_(false), is_placeholder_(false),
-      is_converted_(false), is_circular_(false), seen_(false),
-      seen_in_compare_is_identity_(false), seen_in_get_backend_(false)
+      is_converted_(false), is_circular_(false), is_verified_(false),
+      seen_(false), seen_in_compare_is_identity_(false),
+      seen_in_get_backend_(false)
   { }
 
   // Return the associated Named_object.  This holds the actual name.
@@ -2908,6 +2909,8 @@
   // Whether this is a pointer or function type which refers to the
   // type itself.
   bool is_circular_;
+  // Whether this type has been verified.
+  bool is_verified_;
   // In a recursive operation such as has_hidden_fields, this flag is
   // used to prevent infinite recursion when a type refers to itself.
   // This is mutable because it is always reset to false when the

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Go patch committed: Fix unsafe.Sizeof for named structs
  2012-06-07  5:59 Go patch committed: Fix unsafe.Sizeof for named structs Ian Lance Taylor
@ 2012-06-07  6:23 ` Jakub Jelinek
  2012-06-07  6:35   ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2012-06-07  6:23 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-patches, gofrontend-dev

On Wed, Jun 06, 2012 at 10:49:56PM -0700, Ian Lance Taylor wrote:
> This patch to the Go frontend fixes an embarrassing and serious bug in
> which unsafe.Sizeof returns the wrong value for a named struct that
> has fields that are themselves named structs.  Bootstrapped and ran Go
> testsuite on x86_64-unknown-linux-gnu.  Committed to mainline and 4.7
> branch.

Note that the 4.7 branch is frozen now and all changes need RM acks.

	Jakub

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Go patch committed: Fix unsafe.Sizeof for named structs
  2012-06-07  6:23 ` Jakub Jelinek
@ 2012-06-07  6:35   ` Ian Lance Taylor
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Lance Taylor @ 2012-06-07  6:35 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, gofrontend-dev

Jakub Jelinek <jakub@redhat.com> writes:

> On Wed, Jun 06, 2012 at 10:49:56PM -0700, Ian Lance Taylor wrote:
>> This patch to the Go frontend fixes an embarrassing and serious bug in
>> which unsafe.Sizeof returns the wrong value for a named struct that
>> has fields that are themselves named structs.  Bootstrapped and ran Go
>> testsuite on x86_64-unknown-linux-gnu.  Committed to mainline and 4.7
>> branch.
>
> Note that the 4.7 branch is frozen now and all changes need RM acks.

Sorry, didn't realize.  Hope this one is OK.  It fixes a serious bug and
should not affect bootstrap.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-07  6:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-07  5:59 Go patch committed: Fix unsafe.Sizeof for named structs Ian Lance Taylor
2012-06-07  6:23 ` Jakub Jelinek
2012-06-07  6:35   ` 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).