FAQ
Reviewers: ken2,

Message:
Hello ken2 (cc: golang-dev@googlegroups.com),

I'd like you to review this change to
https://code.google.com/p/go/


Description:
cmd/gc: fix divide by zero error in compiler

Fixes issue 6399.

Please review this at https://codereview.appspot.com/13253055/

Affected files (+28, -1 lines):
    M src/cmd/gc/walk.c
    A test/fixedbugs/issue6399.go


Index: src/cmd/gc/walk.c
===================================================================
--- a/src/cmd/gc/walk.c
+++ b/src/cmd/gc/walk.c
@@ -1295,7 +1295,7 @@
     t = n->type;
     if(n->esc == EscNone
      && smallintconst(l) && smallintconst(r)
- && mpgetfix(r->val.u.xval) < (1ULL<<16) / t->type->width) {
+ && (t->type->width == 0 || mpgetfix(r->val.u.xval) < (1ULL<<16) /
t->type->width)) {
      // var arr [r]T
      // n = arr[:l]
      t = aindex(r, t->type); // [r]T
Index: test/fixedbugs/issue6399.go
===================================================================
new file mode 100644
--- /dev/null
+++ b/test/fixedbugs/issue6399.go
@@ -0,0 +1,27 @@
+// compile
+
+package main
+
+type Foo interface {
+ Print()
+}
+
+type Bar struct{}
+
+func (b Bar) Print() {}
+
+func main() {
+ b := make([]Bar, 20)
+ f := make([]Foo, 20)
+ for i := range f {
+ f[i] = b[i]
+ }
+ T(f)
+ _ = make([]struct{}, 1)
+}
+
+func T(f []Foo) {
+ for i := range f {
+ f[i].Print()
+ }
+}


--

---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Rsc at Sep 16, 2013 at 6:22 pm
    *** Submitted as
    https://code.google.com/p/go/source/detail?r=a972ba4c78a8 ***

    cmd/gc: fix divide by zero error in compiler

    Fixes issue 6399.

    R=ken2
    CC=golang-dev
    https://codereview.appspot.com/13253055


    https://codereview.appspot.com/13253055/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Ken at Sep 16, 2013 at 7:06 pm

    On 2013/09/16 18:22:39, rsc wrote:
    *** Submitted as
    https://code.google.com/p/go/source/detail?r=a972ba4c78a8 ***
    cmd/gc: fix divide by zero error in compiler
    Fixes issue 6399.
    R=ken2
    CC=golang-dev
    https://codereview.appspot.com/13253055

    lgtm


    https://codereview.appspot.com/13253055/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedSep 16, '13 at 6:22p
activeSep 16, '13 at 7:06p
posts3
users2
websitegolang.org

2 users in discussion

Rsc: 2 posts Ken: 1 post

People

Translate

site design / logo © 2022 Grokbase