This patch to the Go frontend by Than McIntosh avoids a compiler crash
on an invalid self-referential type.  The compiler was crashing
partway through emitting an error for a bad self-referential struct
type (which refers to one of its own fields via an unsafe.Offset
expression).  The patch tweaks the offset logic to check for this
class of type error and exit cleanly.  This fixes
https://golang.org/issue/24180.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE     (revision 258052)
+++ gcc/go/gofrontend/MERGE     (working copy)
@@ -1,4 +1,4 @@
-821960465883fbdd96568f2325f55ee4b05de1cb
+262d629b1592f681fef396166a671e46cdb31230
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/expressions.cc
===================================================================
--- gcc/go/gofrontend/expressions.cc    (revision 257954)
+++ gcc/go/gofrontend/expressions.cc    (working copy)
@@ -8224,6 +8224,11 @@ Builtin_call_expression::do_numeric_cons
             return false;
           if (st->named_type() != NULL)
             st->named_type()->convert(this->gogo_);
+          if (st->is_error_type())
+            {
+              go_assert(saw_errors());
+              return false;
+            }
           int64_t offset;
           this->seen_ = true;
           bool ok = st->struct_type()->backend_field_offset(this->gogo_,

Reply via email to