This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Go patch committed: Always check for nil pointer in value method


This patch to the Go frontend changes value methods to always check
that the pointer they are passed is not nil.  We already dereference
the pointer to copy the value, but if the method does not use the
value then the pointer dereference may be optimized away.  Do an
explicit nil check so that we get the panic that is required by the
language.  This fixes https://golang.org/issue/19806.  I added a test
case to gcc/testsuite/go.go-torture/execute to test this at various
optimization levels; the test used to fail at -O1 and above.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian

2018-01-31  Ian Lance Taylor  <iant@golang.org>

* go.go-torture/execute/printnil.go: New test.

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]