diff mbox series

Go patch committed: fix check for notinheap conversion

Message ID CAOyqgcWHaTBUDD4GO-GaHC_4eQ+XbQhpqO_AgYKpLW0GPxJSAg@mail.gmail.com
State New
Headers show
Series Go patch committed: fix check for notinheap conversion | expand

Commit Message

Ian Lance Taylor Sept. 14, 2017, 3:45 a.m. UTC
In the Go frontend, a normal pointer may not be converted to a
notinheap pointer.  The frontend was erroneously permitting a
conversion from a normal pointer to a notinheap unsafe.Pointer, which
is useless since unsafe.Pointer is not marked notinheap.  This patch
corrects the test to permit a conversion from unsafe.Pointer to a
notinheap pointer, which is the same test that the gc compiler uses.

The test case for this is in the upcoming 1.9 runtime package.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
diff mbox series

Patch

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 251948)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
-52ebad939927e6cbfb48dd277cef8db451e36533
+8c6d9ff6f60b737d1e96c0dab0b4e67402bf3316
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/types.cc
===================================================================
--- gcc/go/gofrontend/types.cc	(revision 251948)
+++ gcc/go/gofrontend/types.cc	(working copy)
@@ -747,16 +747,16 @@  Type::are_convertible(const Type* lhs, c
     return true;
 
   // A pointer to a regular type may not be converted to a pointer to
-  // a type that may not live in the heap, except when converting to
+  // a type that may not live in the heap, except when converting from
   // unsafe.Pointer.
   if (lhs->points_to() != NULL
       && rhs->points_to() != NULL
-      && !rhs->points_to()->in_heap()
-      && lhs->points_to()->in_heap()
-      && !lhs->is_unsafe_pointer_type())
+      && !lhs->points_to()->in_heap()
+      && rhs->points_to()->in_heap()
+      && !rhs->is_unsafe_pointer_type())
     {
       if (reason != NULL)
-	reason->assign(_("conversion from notinheap type to normal type"));
+	reason->assign(_("conversion from normal type to notinheap type"));
       return false;
     }