aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/gc/const.c2
-rw-r--r--test/fixedbugs/issue7794.go12
2 files changed, 13 insertions, 1 deletions
diff --git a/src/cmd/gc/const.c b/src/cmd/gc/const.c
index 28d0725d33..f356c4f59a 100644
--- a/src/cmd/gc/const.c
+++ b/src/cmd/gc/const.c
@@ -1594,7 +1594,7 @@ isgoconst(Node *n)
case ONAME:
l = n->sym->def;
- if(l->op == OLITERAL && n->val.ctype != CTNIL)
+ if(l && l->op == OLITERAL && n->val.ctype != CTNIL)
return 1;
break;
diff --git a/test/fixedbugs/issue7794.go b/test/fixedbugs/issue7794.go
new file mode 100644
index 0000000000..1e303bd4f2
--- /dev/null
+++ b/test/fixedbugs/issue7794.go
@@ -0,0 +1,12 @@
+// compile
+
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+func main() {
+ var a [10]int
+ const ca = len(a)
+}