This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
libgo patch committed: Delete from a nil map is now a no-op
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Wed, 12 Dec 2012 15:29:12 -0800
- Subject: libgo patch committed: Delete from a nil map is now a no-op
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
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