public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* libgo patch committed: Delete from a nil map is now a no-op
@ 2012-12-12 23:29 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2012-12-12 23:29 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

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

The Go spec was changed slightly: calling delete on a nil map is now a
no-op, rather than causing a runtime panic.  This patch implements that
in gccgo.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian


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

Index: libgo/runtime/go-map-delete.c
===================================================================
--- libgo/runtime/go-map-delete.c	(revision 194274)
+++ libgo/runtime/go-map-delete.c	(working copy)
@@ -27,7 +27,7 @@ __go_map_delete (struct __go_map *map, c
   void **pentry;
 
   if (map == NULL)
-    runtime_panicstring ("deletion of entry in nil map");
+    return;
 
   descriptor = map->__descriptor;
 
Index: gcc/testsuite/go.test/test/nil.go
===================================================================
--- gcc/testsuite/go.test/test/nil.go	(revision 193595)
+++ gcc/testsuite/go.test/test/nil.go	(working copy)
@@ -151,9 +151,8 @@ func maptest() {
 	shouldPanic(func() {
 		m[2] = 3
 	})
-	shouldPanic(func() {
-		delete(m, 2)
-	})
+	// can delete (non-existent) entries
+	delete(m, 2)
 }
 
 // nil slice

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

only message in thread, other threads:[~2012-12-12 23:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-12 23:29 libgo patch committed: Delete from a nil map is now a no-op 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).