From 63d1e46df06893b073418be4e27f95eebd05ba26 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 20 Apr 2012 19:21:39 +0000 Subject: compiler, runtime: Add explicit checks for zero and overflow division. * lang.opt: Add -fgo-check-divide-zero and -fgo-check-divide-overflow. * gccgo.texi (Invoking gccgo): Document new options. From-SVN: r186637 --- libgo/runtime/go-runtime-error.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libgo') diff --git a/libgo/runtime/go-runtime-error.c b/libgo/runtime/go-runtime-error.c index f732e7f..68db8ac 100644 --- a/libgo/runtime/go-runtime-error.c +++ b/libgo/runtime/go-runtime-error.c @@ -46,7 +46,10 @@ enum MAKE_MAP_OUT_OF_BOUNDS = 8, /* Channel capacity out of bounds in make: negative or overflow. */ - MAKE_CHAN_OUT_OF_BOUNDS = 9 + MAKE_CHAN_OUT_OF_BOUNDS = 9, + + /* Integer division by zero. */ + DIVISION_BY_ZERO = 10 }; extern void __go_runtime_error () __attribute__ ((noreturn)); @@ -78,6 +81,9 @@ __go_runtime_error (int i) case MAKE_CHAN_OUT_OF_BOUNDS: runtime_panicstring ("make chan len out of range"); + case DIVISION_BY_ZERO: + runtime_panicstring ("integer divide by zero"); + default: runtime_panicstring ("unknown runtime error"); } -- cgit v1.1