From ed39c764b886e2b19d07ccb265f6b2cf3535aa98 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Jun 2010 20:34:31 -0700 Subject: [PATCH] gc: do not crash on bad [...]T Fixes #879. R=ken2 CC=golang-dev https://golang.org/cl/1678048 --- src/cmd/gc/align.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cmd/gc/align.c b/src/cmd/gc/align.c index 0d4fa991f3f..1b9112d69a3 100644 --- a/src/cmd/gc/align.c +++ b/src/cmd/gc/align.c @@ -225,6 +225,8 @@ dowidth(Type *t) uint64 cap; dowidth(t->type); + if(t->type->width == 0) + fatal("no width for type %T", t->type); if(tptr == TPTR32) cap = ((uint32)-1) / t->type->width; else @@ -275,6 +277,9 @@ dowidth(Type *t) break; } + // catch all for error cases; avoid divide by zero later + if(w == 0) + w = maxround; t->width = w; lineno = lno;